diff --git a/pkg/controller/template/render.go b/pkg/controller/template/render.go index da9630f575..75718ea470 100644 --- a/pkg/controller/template/render.go +++ b/pkg/controller/template/render.go @@ -410,7 +410,12 @@ func onPremPlatformIngressIP(cfg RenderConfig) (interface{}, error) { case configv1.OpenStackPlatformType: return cfg.Infra.Status.PlatformStatus.OpenStack.IngressIP, nil case configv1.VSpherePlatformType: - return cfg.Infra.Status.PlatformStatus.VSphere.IngressIP, nil + if cfg.Infra.Status.PlatformStatus.VSphere != nil { + return cfg.Infra.Status.PlatformStatus.VSphere.IngressIP, nil + } + // VSphere UPI doesn't populate VSphere field. So it's not an error, + // and there is also no data + return nil, nil default: return nil, fmt.Errorf("invalid platform for Ingress IP") } @@ -429,7 +434,12 @@ func onPremPlatformAPIServerInternalIP(cfg RenderConfig) (interface{}, error) { case configv1.OpenStackPlatformType: return cfg.Infra.Status.PlatformStatus.OpenStack.APIServerInternalIP, nil case configv1.VSpherePlatformType: - return cfg.Infra.Status.PlatformStatus.VSphere.APIServerInternalIP, nil + if cfg.Infra.Status.PlatformStatus.VSphere != nil { + return cfg.Infra.Status.PlatformStatus.VSphere.APIServerInternalIP, nil + } + // VSphere UPI doesn't populate VSphere field. So it's not an error, + // and there is also no data + return nil, nil default: return nil, fmt.Errorf("invalid platform for API Server Internal IP") } diff --git a/templates/common/on-prem/files/NetworkManager-mdns-hostname.yaml b/templates/common/on-prem/files/NetworkManager-mdns-hostname.yaml index 42c010552f..016626220c 100644 --- a/templates/common/on-prem/files/NetworkManager-mdns-hostname.yaml +++ b/templates/common/on-prem/files/NetworkManager-mdns-hostname.yaml @@ -2,6 +2,7 @@ mode: 0755 path: "/etc/NetworkManager/dispatcher.d/40-mdns-hostname" contents: inline: | + {{ if (onPremPlatformAPIServerInternalIP .) -}} #!/bin/bash STATUS=$2 case "$STATUS" in @@ -19,3 +20,4 @@ contents: *) ;; esac + {{ end -}} diff --git a/templates/common/on-prem/files/NetworkManager-onprem.conf.yaml b/templates/common/on-prem/files/NetworkManager-onprem.conf.yaml index 2e2eae359d..13c461306f 100644 --- a/templates/common/on-prem/files/NetworkManager-onprem.conf.yaml +++ b/templates/common/on-prem/files/NetworkManager-onprem.conf.yaml @@ -2,6 +2,7 @@ mode: 0644 path: "/etc/NetworkManager/conf.d/99-{{ onPremPlatformShortName . }}.conf" contents: inline: | + {{ if (onPremPlatformAPIServerInternalIP .) -}} [main] rc-manager=unmanaged [connection] @@ -9,3 +10,4 @@ contents: ipv6.dhcp-iaid=mac [keyfile] path=/etc/NetworkManager/system-connections-merged + {{ end -}} diff --git a/templates/common/on-prem/files/NetworkManager-resolv-prepender.yaml b/templates/common/on-prem/files/NetworkManager-resolv-prepender.yaml index 974406a5c8..8ed0436117 100644 --- a/templates/common/on-prem/files/NetworkManager-resolv-prepender.yaml +++ b/templates/common/on-prem/files/NetworkManager-resolv-prepender.yaml @@ -2,6 +2,7 @@ mode: 0755 path: "/etc/NetworkManager/dispatcher.d/30-resolv-prepender" contents: inline: | + {{ if (onPremPlatformAPIServerInternalIP .) -}} #!/bin/bash set -eo pipefail IFACE=$1 @@ -63,3 +64,4 @@ contents: *) ;; esac + {{ end -}} \ No newline at end of file diff --git a/templates/common/on-prem/files/coredns.yaml b/templates/common/on-prem/files/coredns.yaml index 4e4ddf010b..77672f71d9 100644 --- a/templates/common/on-prem/files/coredns.yaml +++ b/templates/common/on-prem/files/coredns.yaml @@ -2,6 +2,7 @@ mode: 0644 path: "/etc/kubernetes/manifests/coredns.yaml" contents: inline: | + {{ if (onPremPlatformAPIServerInternalIP .) -}} kind: Pod apiVersion: v1 metadata: @@ -116,3 +117,4 @@ contents: - operator: Exists priorityClassName: system-node-critical status: {} + {{ end -}} \ No newline at end of file diff --git a/templates/common/on-prem/files/keepalived.yaml b/templates/common/on-prem/files/keepalived.yaml index 753cf4c3b2..ae48ae4f79 100644 --- a/templates/common/on-prem/files/keepalived.yaml +++ b/templates/common/on-prem/files/keepalived.yaml @@ -2,6 +2,7 @@ mode: 0644 path: "/etc/kubernetes/manifests/keepalived.yaml" contents: inline: | + {{ if (onPremPlatformAPIServerInternalIP .) -}} kind: Pod apiVersion: v1 metadata: @@ -167,3 +168,4 @@ contents: - operator: Exists priorityClassName: system-node-critical status: {} + {{ end -}} \ No newline at end of file diff --git a/templates/common/on-prem/files/mdns-publisher.yaml b/templates/common/on-prem/files/mdns-publisher.yaml index 03ac02508f..5b19213d14 100644 --- a/templates/common/on-prem/files/mdns-publisher.yaml +++ b/templates/common/on-prem/files/mdns-publisher.yaml @@ -2,6 +2,7 @@ mode: 0644 path: "/etc/kubernetes/manifests/mdns-publisher.yaml" contents: inline: | + {{ if (onPremPlatformAPIServerInternalIP .) -}} kind: Pod apiVersion: v1 metadata: @@ -101,3 +102,4 @@ contents: - operator: Exists priorityClassName: system-node-critical status: {} + {{ end -}} \ No newline at end of file diff --git a/templates/common/on-prem/units/nodeip-configuration.service.yaml b/templates/common/on-prem/units/nodeip-configuration.service.yaml index 6c693166f3..21c892aeff 100644 --- a/templates/common/on-prem/units/nodeip-configuration.service.yaml +++ b/templates/common/on-prem/units/nodeip-configuration.service.yaml @@ -1,6 +1,7 @@ name: nodeip-configuration.service enabled: true contents: | + {{ if (onPremPlatformAPIServerInternalIP .) -}} [Unit] Description=Writes IP address configuration so that kubelet and crio services select a valid node IP # This only applies to VIP managing environments where the kubelet and crio IP @@ -44,4 +45,4 @@ contents: | [Install] WantedBy=multi-user.target - + {{ end -}} diff --git a/templates/common/vsphere/files/etc-systemd-system-crio-stream-address.conf.yaml b/templates/common/vsphere/files/etc-systemd-system-crio-stream-address.conf.yaml index d162bce699..03e5106338 100644 --- a/templates/common/vsphere/files/etc-systemd-system-crio-stream-address.conf.yaml +++ b/templates/common/vsphere/files/etc-systemd-system-crio-stream-address.conf.yaml @@ -2,11 +2,7 @@ mode: 0644 path: "/etc/systemd/system/crio.service.d/20-stream-address.conf" contents: inline: | - {{ if .Infra -}} - {{ if .Infra.Status -}} - {{ if .Infra.Status.PlatformStatus -}} - {{ if .Infra.Status.PlatformStatus.VSphere -}} - {{ if .Infra.Status.PlatformStatus.VSphere.APIServerInternalIP -}} + {{ if (onPremPlatformAPIServerInternalIP .) -}} [Service] ExecStart= ExecStart=/usr/bin/crio \ @@ -15,7 +11,3 @@ contents: $CRIO_NETWORK_OPTIONS \ $CRIO_METRICS_OPTIONS {{ end -}} - {{ end -}} - {{ end -}} - {{ end -}} - {{ end -}} diff --git a/templates/master/00-master/on-prem/files/haproxy.yaml b/templates/master/00-master/on-prem/files/haproxy.yaml index e24c26738f..d0bba510f3 100644 --- a/templates/master/00-master/on-prem/files/haproxy.yaml +++ b/templates/master/00-master/on-prem/files/haproxy.yaml @@ -2,6 +2,7 @@ mode: 0644 path: "/etc/kubernetes/manifests/haproxy.yaml" contents: inline: | + {{ if (onPremPlatformAPIServerInternalIP .) -}} kind: Pod apiVersion: v1 metadata: @@ -144,3 +145,4 @@ contents: - operator: Exists priorityClassName: system-node-critical status: {} + {{ end -}} \ No newline at end of file