kubeadm: use correct IP family for etcd localhost

kubeadm always use the IPv4 localhost address by defaultA for etcd

The probe hostname is obtained before the generation of the etcd
parameters, so it can't detect the right IP familiy for the
host of the probe.
This causes that with IPv6 clusters doesn't work because the probe
uses the IPv4 localhost address.

This patchs configures the right localhost address based on the used
AdvertiseAddress IP family.
This commit is contained in:
Antonio Ojea
2019-11-29 07:22:54 +01:00
parent 798d2fb75a
commit 335a3e9efb
7 changed files with 117 additions and 13 deletions

View File

@@ -269,8 +269,11 @@ func GetSchedulerProbeAddress(cfg *kubeadmapi.ClusterConfiguration) string {
// GetEtcdProbeEndpoint takes a kubeadm Etcd configuration object and attempts to parse
// the first URL in the listen-metrics-urls argument, returning an etcd probe hostname,
// port and scheme
func GetEtcdProbeEndpoint(cfg *kubeadmapi.Etcd) (string, int, v1.URIScheme) {
func GetEtcdProbeEndpoint(cfg *kubeadmapi.Etcd, isIPv6 bool) (string, int, v1.URIScheme) {
localhost := "127.0.0.1"
if isIPv6 {
localhost = "::1"
}
if cfg.Local == nil || cfg.Local.ExtraArgs == nil {
return localhost, kubeadmconstants.EtcdMetricsPort, v1.URISchemeHTTP
}