From 3cbe1d2026b731f5f5113563817818e830471789 Mon Sep 17 00:00:00 2001 From: Daniel Lipovetsky Date: Tue, 12 Mar 2024 10:58:34 -0700 Subject: [PATCH] fix: Ensure localhost maps to IPv4 address (#14) --- controllers/cluster_scripts/cloud_init.tmpl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/controllers/cluster_scripts/cloud_init.tmpl b/controllers/cluster_scripts/cloud_init.tmpl index d7823a0f9..6b3f226b0 100644 --- a/controllers/cluster_scripts/cloud_init.tmpl +++ b/controllers/cluster_scripts/cloud_init.tmpl @@ -40,8 +40,18 @@ write_files: # Exit on the first error. Does not apply to commad lists, or pipelines. set -o errexit - # Our images do not require any network customization, - # but CAPVCD requires a successful status to finish bootstrapping. + # Begin network configuration + vmtoolsd --cmd "info-set guestinfo.postcustomization.networkconfiguration.status in_progress" + # Disable IPv6. CAPVCD does not yet support it. + echo '# Added by CAPVCD bootstrap' >> /etc/sysctl.conf + echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> /etc/sysctl.conf + echo 'net.ipv6.conf.default.disable_ipv6 = 1' >> /etc/sysctl.conf + echo 'net.ipv6.conf.lo.disable_ipv6 = 1' >> /etc/sysctl.conf + sudo sysctl -p + # Kubeadm fails to reach kubelet metrics, because VMWare Guest Customization maps localhost to an + # IPv6 address (https://kb.vmware.com/s/article/83138), which does not resolve. This ensures localhost + # resolves to an IPv4 address. + sed -i 's/::1/127.0.0.1/g' /etc/hosts || true vmtoolsd --cmd "info-set guestinfo.postcustomization.networkconfiguration.status successful" # Our images do not ship the VCD metering service, @@ -81,8 +91,6 @@ runcmd: - bash /root/bootstrap.sh timezone: UTC disable_root: false -# Ensure we have an IPv4 address for localhost -manage_etc_hosts: localhost # Ensure that cloud-init can override the hostname. preserve_hostname: false hostname: "{{ .MachineName }}"