Incorrect hostname for VMs with multiple network interfaces
d3c3balus opened this issue · 0 comments
d3c3balus commented
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.