diff --git a/cmd/kube-proxy/app/server_windows.go b/cmd/kube-proxy/app/server_windows.go index ea686c7f4c6..7d77d0c0b1c 100644 --- a/cmd/kube-proxy/app/server_windows.go +++ b/cmd/kube-proxy/app/server_windows.go @@ -25,7 +25,6 @@ import ( "errors" "fmt" "net" - "strconv" // Enable pprof HTTP handlers. _ "net/http/pprof" @@ -83,11 +82,6 @@ func (s *ProxyServer) createProxier(config *proxyconfigapi.KubeProxyConfiguratio if initOnly { return nil, fmt.Errorf("--init-only is not implemented on Windows") } - var healthzPort int - if len(config.HealthzBindAddress) > 0 { - _, port, _ := net.SplitHostPort(config.HealthzBindAddress) - healthzPort, _ = strconv.Atoi(port) - } var proxier proxy.Provider var err error @@ -100,8 +94,8 @@ func (s *ProxyServer) createProxier(config *proxyconfigapi.KubeProxyConfiguratio s.NodeIPs, s.Recorder, s.HealthzServer, + config.HealthzBindAddress, config.Winkernel, - healthzPort, ) } else { proxier, err = winkernel.NewProxier( @@ -112,8 +106,8 @@ func (s *ProxyServer) createProxier(config *proxyconfigapi.KubeProxyConfiguratio s.NodeIPs[s.PrimaryIPFamily], s.Recorder, s.HealthzServer, + config.HealthzBindAddress, config.Winkernel, - healthzPort, ) } if err != nil { diff --git a/pkg/proxy/winkernel/proxier.go b/pkg/proxy/winkernel/proxier.go index 4ecd72ea7df..a1f9bade5f2 100644 --- a/pkg/proxy/winkernel/proxier.go +++ b/pkg/proxy/winkernel/proxier.go @@ -657,8 +657,8 @@ func NewProxier( nodeIP net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxierHealthServer, + healthzBindAddress string, config config.KubeProxyWinkernelConfiguration, - healthzPort int, ) (*Proxier, error) { if nodeIP == nil { klog.InfoS("Invalid nodeIP, initializing kube-proxy with 127.0.0.1 as nodeIP") @@ -669,6 +669,12 @@ func NewProxier( nodePortAddresses := proxyutil.NewNodePortAddresses(ipFamily, nil) serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder, nodePortAddresses, healthzServer) + var healthzPort int + if len(healthzBindAddress) > 0 { + _, port, _ := net.SplitHostPort(healthzBindAddress) + healthzPort, _ = strconv.Atoi(port) + } + hcnImpl := newHcnImpl() hns, supportedFeatures := newHostNetworkService(hcnImpl) hnsNetworkName, err := getNetworkName(config.NetworkName) @@ -787,14 +793,14 @@ func NewDualStackProxier( nodeIPs map[v1.IPFamily]net.IP, recorder events.EventRecorder, healthzServer *healthcheck.ProxierHealthServer, + healthzBindAddress string, config config.KubeProxyWinkernelConfiguration, - healthzPort int, ) (proxy.Provider, error) { // Create an ipv4 instance of the single-stack proxier ipv4Proxier, err := NewProxier(v1.IPv4Protocol, syncPeriod, minSyncPeriod, hostname, nodeIPs[v1.IPv4Protocol], recorder, healthzServer, - config, healthzPort) + healthzBindAddress, config) if err != nil { return nil, fmt.Errorf("unable to create ipv4 proxier: %v, hostname: %s, nodeIP:%v", err, hostname, nodeIPs[v1.IPv4Protocol]) @@ -802,7 +808,7 @@ func NewDualStackProxier( ipv6Proxier, err := NewProxier(v1.IPv6Protocol, syncPeriod, minSyncPeriod, hostname, nodeIPs[v1.IPv6Protocol], recorder, healthzServer, - config, healthzPort) + healthzBindAddress, config) if err != nil { return nil, fmt.Errorf("unable to create ipv6 proxier: %v, hostname: %s, nodeIP:%v", err, hostname, nodeIPs[v1.IPv6Protocol]) }