Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect hostname for VMs with multiple network interfaces #1673

Open
d3c3balus opened this issue Jun 23, 2021 · 0 comments
Open

Incorrect hostname for VMs with multiple network interfaces #1673

d3c3balus opened this issue Jun 23, 2021 · 0 comments

Comments

@d3c3balus
Copy link

Given 2 VPCs:

NAME                    REGION        NETWORK                     RANGE
secondary-subnet-first  europe-west1  vpc-secondary-europe-west1  172.16.0.0/16
subnet-first            europe-west1  vpc-primary-europe-west1    10.1.0.0/16

I create multiple VMs, each with a network connection in each VPC.

NAME         ZONE            MACHINE_TYPE  PREEMPTIBLE  INTERNAL_IP          EXTERNAL_IP  STATUS
k8s-master   europe-west1-b  e2-medium                  10.1.0.2,172.16.0.2               RUNNING
k8s-worker1  europe-west1-b  e2-medium                  10.1.0.3,172.16.0.3               RUNNING
k8s-worker2  europe-west1-b  e2-medium                  10.1.0.4,172.16.0.4               RUNNING

Although, nic0 points to vpc-primary-europe-west1 (subnet 10.1.0.0/16), the /etc/hosts file contains wrong IP (from the secondary VPC, nic1):

# cat /etc/hosts
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
169.254.169.254 metadata.google.internal metadata
172.16.0.2 k8s-master.europe-west1-b.c.k8snet.internal k8s-master  # Added by Google
169.254.169.254 metadata.google.internal  # Added by Google

Note the row marked as "Added by Google".

Additional info: the default route is correctly using nic0 (primary VPC):

default via 10.1.0.1 dev ens4 proto dhcp src 10.1.0.2 metric 100 
10.1.0.0/16 via 10.1.0.1 dev ens4 proto dhcp src 10.1.0.2 metric 100 
10.1.0.1 dev ens4 proto dhcp scope link src 10.1.0.2 metric 100 
172.16.0.0/16 via 172.16.0.1 dev ens5 
172.16.0.1 dev ens5 scope link 

Conclusion: GCP incorrectly sets the hostname for the secondary IP instead of the IP of nic0.
Impact: some tools (e.g. Kubelet) uses the IP of the hostname of the node and incorrectly uses the secondary IP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant