diff --git a/data/data/bootstrap/systemd/units/kubelet.service.template b/data/data/bootstrap/systemd/units/kubelet.service.template index 1888ddeea8e..847107aec0e 100644 --- a/data/data/bootstrap/systemd/units/kubelet.service.template +++ b/data/data/bootstrap/systemd/units/kubelet.service.template @@ -18,6 +18,9 @@ ExecStart=/usr/bin/hyperkube \ --container-runtime=remote \ --container-runtime-endpoint=/var/run/crio/crio.sock \ --runtime-request-timeout=${KUBELET_RUNTIME_REQUEST_TIMEOUT} \ +{{- if .UseIPv6ForNodeIP }} + --node-ip=:: \ +{{- end}} --pod-manifest-path=/etc/kubernetes/manifests \ --minimum-container-ttl-duration=6m0s \ --cluster-domain=cluster.local \ diff --git a/pkg/asset/ignition/bootstrap/bootstrap.go b/pkg/asset/ignition/bootstrap/bootstrap.go index 08c3e7c2b69..961eaff919d 100644 --- a/pkg/asset/ignition/bootstrap/bootstrap.go +++ b/pkg/asset/ignition/bootstrap/bootstrap.go @@ -8,6 +8,7 @@ import ( "fmt" "io" "io/ioutil" + "net" "os" "path" "path/filepath" @@ -59,6 +60,7 @@ type bootstrapTemplateData struct { Registries []sysregistriesv2.Registry BootImage string PlatformData platformTemplateData + UseIPv6ForNodeIP bool } // platformTemplateData is the data to use to replace values in bootstrap @@ -260,6 +262,14 @@ func (a *Bootstrap) getTemplateData(installConfig *types.InstallConfig, releaseI platformData.VSphere = vsphere.GetTemplateData(installConfig.Platform.VSphere) } + var APIIntVIPonIPv6 bool + platformAPIVIP := apiVIP(&installConfig.Platform) + if platformAPIVIP == "" { + APIIntVIPonIPv6 = false + } else { + APIIntVIPonIPv6 = net.ParseIP(platformAPIVIP).To4() == nil + } + // Set cluster profile clusterProfile := "" if cp := os.Getenv("OPENSHIFT_INSTALL_EXPERIMENTAL_CLUSTER_PROFILE"); cp != "" { @@ -278,6 +288,7 @@ func (a *Bootstrap) getTemplateData(installConfig *types.InstallConfig, releaseI BootImage: string(*rhcosImage), PlatformData: platformData, ClusterProfile: clusterProfile, + UseIPv6ForNodeIP: APIIntVIPonIPv6, }, nil } @@ -621,3 +632,24 @@ func warnIfCertificatesExpired(config *igntypes.Config) { logrus.Warnf("Bootstrap Ignition-Config: %d certificates expired. Installation attempts with the created Ignition-Configs will possibly fail.", expiredCerts) } } + +// APIVIP returns a string representation of the platform's API VIP +// It returns an empty string if the platform does not configure a VIP +func apiVIP(p *types.Platform) string { + switch { + case p == nil: + return "" + case p.BareMetal != nil: + return p.BareMetal.APIVIP + case p.OpenStack != nil: + return p.OpenStack.APIVIP + case p.VSphere != nil: + return p.VSphere.APIVIP + case p.Ovirt != nil: + return p.Ovirt.APIVIP + case p.Kubevirt != nil: + return p.Kubevirt.APIVIP + default: + return "" + } +}