Skip to content

Commit 032c091

Browse files
committed
Use service CIDRs to determine bootstrap kubelet IP family
The bootstrap kubelet needs to pick a node IP of the cluster's primary IP family (to ensure that the bootstrap apiserver will advertise an IP of that family, matching the family of the kubernetes.default service). Previously it was doing this based on the apiVIPs, but those may not be defined in the install-config for UPI. Instead, base it on the service CIDR. (The install-config validation ensures that all of the values that *are* specified agree on the IP families, so this will still pick the same family as the old code did when apiVIPs is specified.)
1 parent 9b51313 commit 032c091

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

pkg/asset/ignition/bootstrap/common.go

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,15 @@ func (a *Common) getTemplateData(dependencies asset.Parents, bootstrapInPlace bo
300300
bootstrapNodeIP = ""
301301
}
302302

303-
platformFirstAPIVIP := firstAPIVIP(&installConfig.Config.Platform)
304-
APIIntVIPonIPv6 := utilsnet.IsIPv6String(platformFirstAPIVIP)
305-
306-
var hasIPv4, hasIPv6 bool
307-
for _, snet := range installConfig.Config.ServiceNetwork {
303+
var hasIPv4, hasIPv6, ipv6Primary bool
304+
for i, snet := range installConfig.Config.ServiceNetwork {
308305
if utilsnet.IsIPv4(snet.IP) {
309306
hasIPv4 = true
310307
} else {
311308
hasIPv6 = true
309+
if i == 0 {
310+
ipv6Primary = true
311+
}
312312
}
313313
}
314314

@@ -341,7 +341,7 @@ func (a *Common) getTemplateData(dependencies asset.Parents, bootstrapInPlace bo
341341
PlatformData: platformData,
342342
ClusterProfile: clusterProfile,
343343
BootstrapInPlace: bootstrapInPlaceConfig,
344-
UseIPv6ForNodeIP: APIIntVIPonIPv6,
344+
UseIPv6ForNodeIP: ipv6Primary,
345345
UseDualForNodeIP: hasIPv4 && hasIPv6,
346346
IsFCOS: installConfig.Config.IsFCOS(),
347347
IsSCOS: installConfig.Config.IsSCOS(),
@@ -703,34 +703,3 @@ func warnIfCertificatesExpired(config *igntypes.Config) {
703703
logrus.Warnf("Bootstrap Ignition-Config: %d certificates expired. Installation attempts with the created Ignition-Configs will possibly fail.", expiredCerts)
704704
}
705705
}
706-
707-
// APIVIPs returns the string representations of the platform's API VIPs
708-
// It returns nil if the platform does not configure VIPs
709-
func apiVIPs(p *types.Platform) []string {
710-
switch {
711-
case p == nil:
712-
return nil
713-
case p.BareMetal != nil:
714-
return p.BareMetal.APIVIPs
715-
case p.OpenStack != nil:
716-
return p.OpenStack.APIVIPs
717-
case p.VSphere != nil:
718-
return p.VSphere.APIVIPs
719-
case p.Ovirt != nil:
720-
return p.Ovirt.APIVIPs
721-
case p.Nutanix != nil:
722-
return p.Nutanix.APIVIPs
723-
default:
724-
return nil
725-
}
726-
}
727-
728-
// firstAPIVIP returns the first VIP of the API server (e.g. in case of
729-
// dual-stack)
730-
func firstAPIVIP(p *types.Platform) string {
731-
for _, vip := range apiVIPs(p) {
732-
return vip
733-
}
734-
735-
return ""
736-
}

0 commit comments

Comments
 (0)