diff --git a/templates/common/gcp/files/usr-local-bin-update-etc-hosts.yaml b/templates/common/gcp/files/usr-local-bin-update-etc-hosts.yaml new file mode 100644 index 0000000000..0dcfe5fbb6 --- /dev/null +++ b/templates/common/gcp/files/usr-local-bin-update-etc-hosts.yaml @@ -0,0 +1,11 @@ +mode: 0755 +path: "/usr/local/bin/update-etc-hosts" +contents: + inline: | + #!/bin/bash + etc_hosts_config_filename="/etc/conf.d/etc-hosts.conf" + if [ ! -f "$etc_hosts_config_filename" ]; then + exit 0 + fi + cat /etc/conf.d/etc-hosts.conf >> /etc/hosts + echo "Done updating /etc/hosts" diff --git a/templates/common/gcp/units/gcp-update-etc-hosts.service.yaml b/templates/common/gcp/units/gcp-update-etc-hosts.service.yaml new file mode 100644 index 0000000000..865fc6177b --- /dev/null +++ b/templates/common/gcp/units/gcp-update-etc-hosts.service.yaml @@ -0,0 +1,34 @@ +name: gcp-update-etc-hosts.service +enabled: {{if and (eq .Infra.Status.PlatformStatus.Type "GCP") (.Infra.Status.PlatformStatus.GCP) (.Infra.Status.PlatformStatus.GCP.CloudLoadBalancerConfig) (eq .Infra.Status.PlatformStatus.GCP.CloudLoadBalancerConfig.DNSType "ClusterHosted") }}true{{else}}false{{end}} +contents: | + [Unit] + Description=Update Default GCP /etc/hosts + # We don't need to do this on the firstboot + After=firstboot-osupdate.target + # Wait for NetworkManager to report it's online + After=NetworkManager-wait-online.service + # Run before kubelet + Before=kubelet-dependencies.target + + [Service] + # Need oneshot to delay kubelet + Type=oneshot + ExecStart=/bin/bash -c " \ + {{- if and (cloudPlatformLBIPAvailable .) (gt (len (cloudPlatformAPIIntLoadBalancerIPs .)) 0) }} apiIntLBIPs={{ cloudPlatformAPIIntLoadBalancerIPs . }} {{end -}} \ + {{- if and (cloudPlatformLBIPAvailable .) (gt (len (cloudPlatformAPILoadBalancerIPs .)) 0) }} apiLBIPs={{ cloudPlatformAPILoadBalancerIPs . }} {{end -}} \ + if [ -z "$apiLBIPs" ]; then \ + apiLBIPs=$apiIntLBIPs \ + fi \ + apiServerURL={{ .Infra.Status.APIServerURL }} \ + apiServerIntURL={{ .Infra.Status.APIServerInternalURL }} \ + mkdir -p /etc/conf.d \ + cat <