主机名未在同一网络中解析为CE

时间:2019-12-01 14:07:09

标签: google-cloud-platform google-deployment-manager

我正在2个不同的区域(在europe-west1-c中的堡垒和在europe-west2-c中的其他堡垒)部署4 CE。我可以使用主机名从cassandra-node-1切换到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

根据this GCP documentation,如果我为CE选择一个自定义名称,则需要编辑DNS。但是另一方面,如果我在部署管理器配置中未提供name:,则在尝试部署时会出现以下错误:

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

1 个答案:

答案 0 :(得分:2)

您有两种解决方案:

  1. 使用Google Cloud DNS并设置一个专用区域来解析您的VPC的主机名。
  2. 使用Compute Engine内部DNS名称。

但是,对于方法2,我不记得是否将跨区域解析内部名称的主机名解析,因为Compute Engine内部DNS用于名称解析。只要正确设置了DNS,方法1就会一直有效。