google-cloud-platform - 主机名无法解析同一网络中的 CE
问题描述
我正在 2 个不同的区域(europe-west1-c 中的堡垒和 europe-west2-c 中的其他堡垒)部署 4 个 CE。我可以使用主机名从 cassandra-node-1 SSH 到 cassandra-node-2:
pedro_gordo_gmail_com@cassandra-node-1:~$ ssh cassandra-node-2
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.15.0-1049-gcp x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
0 packages can be updated.
0 updates are security updates.
New release '18.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Sun Dec 1 13:48:17 2019 from 10.154.0.14
groups: cannot find name for group ID 926993188
但我不能从堡垒 CE 做同样的事情:
pedro_gordo_gmail_com@bastion:~$ ssh cassandra-node-1
ssh: Could not resolve hostname cassandra-node-1: Name or service not known
但我可以使用内部/外部 IP 进行 ssh:
pedro_gordo_gmail_com@bastion:~$ ssh 10.154.0.14
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.15.0-1049-gcp x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
* Overheard at KubeCon: "microk8s.status just blew my mind".
https://microk8s.io/docs/commands#microk8s.status
0 packages can be updated.
0 updates are security updates.
New release '18.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Sun Dec 1 13:48:10 2019 from 173.194.92.32
groups: cannot find name for group ID 926993188
根据这个 GCP 文档,如果我为我的 CE 选择一个自定义名称,那么我需要编辑 DNS。但另一方面,如果我没有name:
在我的部署管理器配置中提供 a,那么当我尝试部署时会出现以下错误:
gcloud deployment-manager deployments create cluster --config create-vms.yaml
ERROR: (gcloud.deployment-manager.deployments.create) ResponseError: code=412, message=Missing resource name in resource "type: compute.v1.instance
这是我的部署管理器配置。如何更改此设置,以便仅使用主机名就可以从堡垒 ssh 到 cassandra-node-1/2/3?
# Copyright 2016 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Import all templates used in deployment
# Declare all resources. In this case, one highly available service
# as defined in the ha-service.py template.
resources:
- type: compute.v1.instance
name: bastion
properties:
zone: europe-west1-c
machineType: https://www.googleapis.com/compute/v1/projects/affable-seat-213016/zones/europe-west1-c/machineTypes/n1-standard-1
disks:
- deviceName: boot
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20190514
networkInterfaces:
- accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
metadata:
items:
- key: startup-script
value: |
#!/bin/bash
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible
- type: compute.v1.instance
name: cassandra-node-1
properties:
zone: europe-west2-c
machineType: https://www.googleapis.com/compute/v1/projects/affable-seat-213016/zones/europe-west2-c/machineTypes/n1-standard-1
disks:
- deviceName: boot
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20190514
- deviceName: data
boot: false
autoDelete: true
initializeParams:
diskSizeGb: 1
diskType: zones/europe-west2-c/diskTypes/pd-ssd
networkInterfaces:
- accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
- type: compute.v1.instance
name: cassandra-node-2
properties:
zone: europe-west2-c
machineType: projects/affable-seat-213016/zones/europe-west2-c/machineTypes/n1-standard-1
disks:
- deviceName: boot
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20190514
- deviceName: data
boot: false
autoDelete: true
initializeParams:
diskSizeGb: 1
diskType: zones/europe-west2-c/diskTypes/pd-ssd
networkInterfaces:
- accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
- type: compute.v1.instance
name: cassandra-node-3
properties:
zone: europe-west2-c
machineType: https://www.googleapis.com/compute/v1/projects/affable-seat-213016/zones/europe-west2-c/machineTypes/n1-standard-1
disks:
- deviceName: boot
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20190514
- deviceName: data
boot: false
autoDelete: true
initializeParams:
diskSizeGb: 1
diskType: zones/europe-west2-c/diskTypes/pd-ssd
networkInterfaces:
- accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
解决方案
你有两个解决方案:
- 使用 Google Cloud DNS 并设置私有区域来解析您的 VPC 的主机名。
- 使用 Compute Engine 内部 DNS 名称。
但是,对于方法 #2,我不记得内部名称的主机名解析是否跨区域解析,因为 Compute Engine 内部 DNS 用于名称解析。如果 DNS 设置正确,方法 #1 将始终有效。
推荐阅读
- react-admin - react-admin 中的自定义搜索过滤器
- c# - 如何使用 LINQ 在一个集合中找到与另一个集合中的项目匹配的项目?
- javascript - 我如何只能产生 1 次随机值
- angular - Angular中的ng-list等价物?
- r - Shiny中的反应性总结功能
- db2 - 更改密码时出错 DB2 社区版 SQL30083N
- java - How to assign value inside a Runnable Thread
- azure - 如何使用 Azure 数据工厂 GUI 将多个 blob 文件压缩到一个 .gzip 中?
- c# - 如何从压缩文件夹中获取文件并编码并将它们保存到数据库而不提取文件?
- mongodb - webflux returns a list of empty objects