Skip to content

Commit 013459b

Browse files
committed
OCPBUGS-18641: Set dual-stack IPFamilyPriority for vSphere
We have discovered that in dual-stack setups NodeAddresses field of the instance metadata contains only IPv4 addresses for VMs that do have both IPv4 and IPv6 addresses assigned (and detected by the VM agent). It has been traced back to the function responsible for populating this metadata field. We found out that for our configuration we always filter only IPv4 addresses even if running in dual-stack. Reason for that is that `IPFamilyPriority` has a value of `ipv4` even when running in a dual-stack setup. This causes an issue because this instance metadata is cross-checked with addresses provided by the kubelet as part of the `alpha.kubernetes.io/provided-node-ip` annotation. Without correct value of `IPFamilyPriority` we are thus removing all the IPv6 addresses. This PR takes advantage of the Service Networks configured by the user in install-config and the fact that we only allow 2 networks to be configured if the setup is dual-stack. Fixes: OCPBUGS-18641
1 parent 786dda4 commit 013459b

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

pkg/cloud/vsphere/assets/cloud-controller-manager-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ spec:
6666
value: {{ .globalCredsSecretNamespace }}
6767
- name: VSPHERE_SECRET_NAME
6868
value: {{ .globalCredsSecretName }}
69+
- name: ENABLE_ALPHA_DUAL_STACK
70+
value: "true"
6971
resources:
7072
requests:
7173
cpu: 200m

pkg/cloud/vsphere/vsphere_config_transformer.go

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66

77
configv1 "github.com/openshift/api/config/v1"
8+
"k8s.io/utils/net"
89

910
ccmConfig "github.com/openshift/cluster-cloud-controller-manager-operator/pkg/cloud/vsphere/vsphere_cloud_config"
1011
)
@@ -26,7 +27,7 @@ const (
2627
// Currently, CloudConfigTransformer is responsible to populate vcenters, labels, and node networking parameters from
2728
// the Infrastructure resource.
2829
// Also, this function converts legacy deprecated INI configuration format to a YAML-based one.
29-
func CloudConfigTransformer(source string, infra *configv1.Infrastructure, _ *configv1.Network) (string, error) {
30+
func CloudConfigTransformer(source string, infra *configv1.Infrastructure, network *configv1.Network) (string, error) {
3031
if infra.Status.PlatformStatus == nil ||
3132
infra.Status.PlatformStatus.Type != configv1.VSpherePlatformType {
3233
return "", fmt.Errorf("invalid platform, expected to be %s", configv1.VSpherePlatformType)
@@ -42,6 +43,7 @@ func CloudConfigTransformer(source string, infra *configv1.Infrastructure, _ *co
4243
// https://github.com/openshift/enhancements/blob/f6b33eb0cd4ba060af71fee6192297cf6bc31e5a/enhancements/installer/vsphere-ipi-zonal.md
4344
// https://github.com/openshift/api/pull/1278
4445
if infra.Spec.PlatformSpec.VSphere != nil {
46+
setDualStack(cpiCfg, infra.Status.PlatformStatus.VSphere, &infra.Spec.PlatformSpec.VSphere.NodeNetworking, network)
4547
setNodes(cpiCfg, &infra.Spec.PlatformSpec.VSphere.NodeNetworking)
4648
setVirtualCenters(cpiCfg, infra.Spec.PlatformSpec.VSphere)
4749

@@ -99,3 +101,41 @@ func setVirtualCenters(cfg *ccmConfig.CPIConfig, vSphereSpec *configv1.VSpherePl
99101
}
100102
}
101103
}
104+
105+
// setDualStack updates the configuration required by the cloud-provider-vsphere to explicitly set
106+
// value of IPFamilyPriority instead of using the default which is IPv4. This is needed by the
107+
// cloud provider in order to properly filter IP addresses that feed the instance metadata.
108+
//
109+
// We rely on the Service Networks configuration that initially comes from o/installer and later
110+
// from the Cluster Network Operator as those two components take care of validating that clusters
111+
// with dual-stack configuration have exactly 2 of them and that they match the required order.
112+
//
113+
// We are mangling with the ExcludeNetworkSubnetCIDR param here because VM agent by default detects
114+
// also IP addresses that are used by us internally and which should never be exposed as node IPs
115+
// (i.e. API VIP and Ingress VIP for IPI installations and fd69::2 which is internal to OVN-K8s).
116+
//
117+
// Ref.: https://issues.redhat.com/browse/OCPBUGS-18641
118+
func setDualStack(cfg *ccmConfig.CPIConfig, status *configv1.VSpherePlatformStatus, nodeNetworking *configv1.VSpherePlatformNodeNetworking, network *configv1.Network) {
119+
if network != nil && len(network.Spec.ServiceNetwork) == 2 {
120+
if net.IsIPv4String(network.Spec.ServiceNetwork[0]) {
121+
cfg.Global.IPFamilyPriority = []string{"ipv4", "ipv6"}
122+
} else {
123+
cfg.Global.IPFamilyPriority = []string{"ipv6", "ipv4"}
124+
}
125+
126+
if status != nil {
127+
for _, addr := range append(status.APIServerInternalIPs, status.IngressIPs...) {
128+
if net.IsIPv4String(addr) {
129+
addr = addr + "/32"
130+
} else {
131+
addr = addr + "/128"
132+
}
133+
nodeNetworking.External.ExcludeNetworkSubnetCIDR = append(nodeNetworking.External.ExcludeNetworkSubnetCIDR, addr)
134+
nodeNetworking.Internal.ExcludeNetworkSubnetCIDR = append(nodeNetworking.Internal.ExcludeNetworkSubnetCIDR, addr)
135+
}
136+
}
137+
138+
nodeNetworking.External.ExcludeNetworkSubnetCIDR = append(nodeNetworking.External.ExcludeNetworkSubnetCIDR, "fd69::2/128")
139+
nodeNetworking.Internal.ExcludeNetworkSubnetCIDR = append(nodeNetworking.Internal.ExcludeNetworkSubnetCIDR, "fd69::2/128")
140+
}
141+
}

0 commit comments

Comments
 (0)