mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-04 10:47:25 +00:00
Reorganize a bit of winkernel proxier setup
Rather than doing winkernel-specific parsing of generic config data in cmd/kube-proxy, do it in pkg/proxy/winkernel.
This commit is contained in:
@@ -25,7 +25,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
// Enable pprof HTTP handlers.
|
// Enable pprof HTTP handlers.
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
@@ -83,11 +82,6 @@ func (s *ProxyServer) createProxier(config *proxyconfigapi.KubeProxyConfiguratio
|
|||||||
if initOnly {
|
if initOnly {
|
||||||
return nil, fmt.Errorf("--init-only is not implemented on Windows")
|
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 proxier proxy.Provider
|
||||||
var err error
|
var err error
|
||||||
@@ -100,8 +94,8 @@ func (s *ProxyServer) createProxier(config *proxyconfigapi.KubeProxyConfiguratio
|
|||||||
s.NodeIPs,
|
s.NodeIPs,
|
||||||
s.Recorder,
|
s.Recorder,
|
||||||
s.HealthzServer,
|
s.HealthzServer,
|
||||||
|
config.HealthzBindAddress,
|
||||||
config.Winkernel,
|
config.Winkernel,
|
||||||
healthzPort,
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
proxier, err = winkernel.NewProxier(
|
proxier, err = winkernel.NewProxier(
|
||||||
@@ -112,8 +106,8 @@ func (s *ProxyServer) createProxier(config *proxyconfigapi.KubeProxyConfiguratio
|
|||||||
s.NodeIPs[s.PrimaryIPFamily],
|
s.NodeIPs[s.PrimaryIPFamily],
|
||||||
s.Recorder,
|
s.Recorder,
|
||||||
s.HealthzServer,
|
s.HealthzServer,
|
||||||
|
config.HealthzBindAddress,
|
||||||
config.Winkernel,
|
config.Winkernel,
|
||||||
healthzPort,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -657,8 +657,8 @@ func NewProxier(
|
|||||||
nodeIP net.IP,
|
nodeIP net.IP,
|
||||||
recorder events.EventRecorder,
|
recorder events.EventRecorder,
|
||||||
healthzServer *healthcheck.ProxierHealthServer,
|
healthzServer *healthcheck.ProxierHealthServer,
|
||||||
|
healthzBindAddress string,
|
||||||
config config.KubeProxyWinkernelConfiguration,
|
config config.KubeProxyWinkernelConfiguration,
|
||||||
healthzPort int,
|
|
||||||
) (*Proxier, error) {
|
) (*Proxier, error) {
|
||||||
if nodeIP == nil {
|
if nodeIP == nil {
|
||||||
klog.InfoS("Invalid nodeIP, initializing kube-proxy with 127.0.0.1 as nodeIP")
|
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)
|
nodePortAddresses := proxyutil.NewNodePortAddresses(ipFamily, nil)
|
||||||
serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder, nodePortAddresses, healthzServer)
|
serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder, nodePortAddresses, healthzServer)
|
||||||
|
|
||||||
|
var healthzPort int
|
||||||
|
if len(healthzBindAddress) > 0 {
|
||||||
|
_, port, _ := net.SplitHostPort(healthzBindAddress)
|
||||||
|
healthzPort, _ = strconv.Atoi(port)
|
||||||
|
}
|
||||||
|
|
||||||
hcnImpl := newHcnImpl()
|
hcnImpl := newHcnImpl()
|
||||||
hns, supportedFeatures := newHostNetworkService(hcnImpl)
|
hns, supportedFeatures := newHostNetworkService(hcnImpl)
|
||||||
hnsNetworkName, err := getNetworkName(config.NetworkName)
|
hnsNetworkName, err := getNetworkName(config.NetworkName)
|
||||||
@@ -787,14 +793,14 @@ func NewDualStackProxier(
|
|||||||
nodeIPs map[v1.IPFamily]net.IP,
|
nodeIPs map[v1.IPFamily]net.IP,
|
||||||
recorder events.EventRecorder,
|
recorder events.EventRecorder,
|
||||||
healthzServer *healthcheck.ProxierHealthServer,
|
healthzServer *healthcheck.ProxierHealthServer,
|
||||||
|
healthzBindAddress string,
|
||||||
config config.KubeProxyWinkernelConfiguration,
|
config config.KubeProxyWinkernelConfiguration,
|
||||||
healthzPort int,
|
|
||||||
) (proxy.Provider, error) {
|
) (proxy.Provider, error) {
|
||||||
|
|
||||||
// Create an ipv4 instance of the single-stack proxier
|
// Create an ipv4 instance of the single-stack proxier
|
||||||
ipv4Proxier, err := NewProxier(v1.IPv4Protocol, syncPeriod, minSyncPeriod,
|
ipv4Proxier, err := NewProxier(v1.IPv4Protocol, syncPeriod, minSyncPeriod,
|
||||||
hostname, nodeIPs[v1.IPv4Protocol], recorder, healthzServer,
|
hostname, nodeIPs[v1.IPv4Protocol], recorder, healthzServer,
|
||||||
config, healthzPort)
|
healthzBindAddress, config)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to create ipv4 proxier: %v, hostname: %s, nodeIP:%v", err, hostname, nodeIPs[v1.IPv4Protocol])
|
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,
|
ipv6Proxier, err := NewProxier(v1.IPv6Protocol, syncPeriod, minSyncPeriod,
|
||||||
hostname, nodeIPs[v1.IPv6Protocol], recorder, healthzServer,
|
hostname, nodeIPs[v1.IPv6Protocol], recorder, healthzServer,
|
||||||
config, healthzPort)
|
healthzBindAddress, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to create ipv6 proxier: %v, hostname: %s, nodeIP:%v", err, hostname, nodeIPs[v1.IPv6Protocol])
|
return nil, fmt.Errorf("unable to create ipv6 proxier: %v, hostname: %s, nodeIP:%v", err, hostname, nodeIPs[v1.IPv6Protocol])
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user