Skip to content

Commit 715b6af

Browse files
authored
Merge pull request kubernetes#84711 from chendotjs/kubelet-fixip
Refactor: use existing function to simplify check for IPv6 in kubelet
2 parents 7c7ae97 + 5381c9a commit 715b6af

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pkg/kubelet/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ go_library(
147147
"//vendor/k8s.io/klog:go_default_library",
148148
"//vendor/k8s.io/utils/exec:go_default_library",
149149
"//vendor/k8s.io/utils/integer:go_default_library",
150+
"//vendor/k8s.io/utils/net:go_default_library",
150151
"//vendor/k8s.io/utils/path:go_default_library",
151152
],
152153
)

pkg/kubelet/kubelet.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ import (
119119
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
120120
utilexec "k8s.io/utils/exec"
121121
"k8s.io/utils/integer"
122+
utilnet "k8s.io/utils/net"
122123
)
123124

124125
const (
@@ -484,7 +485,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
484485
httpClient := &http.Client{}
485486
parsedNodeIP := net.ParseIP(nodeIP)
486487
protocol := utilipt.ProtocolIpv4
487-
if parsedNodeIP != nil && parsedNodeIP.To4() == nil {
488+
if utilnet.IsIPv6(parsedNodeIP) {
488489
klog.V(0).Infof("IPv6 node IP (%s), assume IPv6 operation", nodeIP)
489490
protocol = utilipt.ProtocolIpv6
490491
}

0 commit comments

Comments
 (0)