pkg/proxy: add an ipFamily field to the winkernel proxier
Signed-off-by: Daman Arora <aroradaman@gmail.com>
This commit is contained in:
		@@ -96,6 +96,7 @@ func (s *ProxyServer) createProxier(config *proxyconfigapi.KubeProxyConfiguratio
 | 
			
		||||
		)
 | 
			
		||||
	} else {
 | 
			
		||||
		proxier, err = winkernel.NewProxier(
 | 
			
		||||
			s.PrimaryIPFamily,
 | 
			
		||||
			config.IPTables.SyncPeriod.Duration,
 | 
			
		||||
			config.IPTables.MinSyncPeriod.Duration,
 | 
			
		||||
			config.ClusterCIDR,
 | 
			
		||||
 
 | 
			
		||||
@@ -590,6 +590,8 @@ type endPointsReferenceCountMap map[string]*uint16
 | 
			
		||||
// Proxier is an hns based proxy for connections between a localhost:lport
 | 
			
		||||
// and services that provide the actual backends.
 | 
			
		||||
type Proxier struct {
 | 
			
		||||
	// ipFamily defines the IP family which this proxier is tracking.
 | 
			
		||||
	ipFamily v1.IPFamily
 | 
			
		||||
	// TODO(imroc): implement node handler for winkernel proxier.
 | 
			
		||||
	proxyconfig.NoopNodeHandler
 | 
			
		||||
 | 
			
		||||
@@ -608,7 +610,6 @@ type Proxier struct {
 | 
			
		||||
	// with some partial data after kube-proxy restart.
 | 
			
		||||
	endpointSlicesSynced bool
 | 
			
		||||
	servicesSynced       bool
 | 
			
		||||
	isIPv6Mode           bool
 | 
			
		||||
	initialized          int32
 | 
			
		||||
	syncRunner           *async.BoundedFrequencyRunner // governs calls to syncProxyRules
 | 
			
		||||
	// These are effectively const and do not need the mutex to be held.
 | 
			
		||||
@@ -666,6 +667,7 @@ var _ proxy.Provider = &Proxier{}
 | 
			
		||||
 | 
			
		||||
// NewProxier returns a new Proxier
 | 
			
		||||
func NewProxier(
 | 
			
		||||
	ipFamily v1.IPFamily,
 | 
			
		||||
	syncPeriod time.Duration,
 | 
			
		||||
	minSyncPeriod time.Duration,
 | 
			
		||||
	clusterCIDR string,
 | 
			
		||||
@@ -685,12 +687,6 @@ func NewProxier(
 | 
			
		||||
		klog.InfoS("ClusterCIDR not specified, unable to distinguish between internal and external traffic")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	isIPv6 := netutils.IsIPv6(nodeIP)
 | 
			
		||||
	ipFamily := v1.IPv4Protocol
 | 
			
		||||
	if isIPv6 {
 | 
			
		||||
		ipFamily = v1.IPv6Protocol
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// windows listens to all node addresses
 | 
			
		||||
	nodePortAddresses := proxyutil.NewNodePortAddresses(ipFamily, nil)
 | 
			
		||||
	serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder, nodePortAddresses, healthzServer)
 | 
			
		||||
@@ -771,6 +767,7 @@ func NewProxier(
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	proxier := &Proxier{
 | 
			
		||||
		ipFamily:              ipFamily,
 | 
			
		||||
		endPointsRefCount:     make(endPointsReferenceCountMap),
 | 
			
		||||
		svcPortMap:            make(proxy.ServicePortMap),
 | 
			
		||||
		endpointsMap:          make(proxy.EndpointsMap),
 | 
			
		||||
@@ -786,7 +783,6 @@ func NewProxier(
 | 
			
		||||
		hostMac:               hostMac,
 | 
			
		||||
		isDSR:                 isDSR,
 | 
			
		||||
		supportedFeatures:     supportedFeatures,
 | 
			
		||||
		isIPv6Mode:            isIPv6,
 | 
			
		||||
		healthzPort:           healthzPort,
 | 
			
		||||
		rootHnsEndpointName:   config.RootHnsEndpointName,
 | 
			
		||||
		forwardHealthCheckVip: config.ForwardHealthCheckVip,
 | 
			
		||||
@@ -817,7 +813,7 @@ func NewDualStackProxier(
 | 
			
		||||
) (proxy.Provider, error) {
 | 
			
		||||
 | 
			
		||||
	// Create an ipv4 instance of the single-stack proxier
 | 
			
		||||
	ipv4Proxier, err := NewProxier(syncPeriod, minSyncPeriod,
 | 
			
		||||
	ipv4Proxier, err := NewProxier(v1.IPv4Protocol, syncPeriod, minSyncPeriod,
 | 
			
		||||
		clusterCIDR, hostname, nodeIPs[v1.IPv4Protocol], recorder, healthzServer,
 | 
			
		||||
		config, healthzPort)
 | 
			
		||||
 | 
			
		||||
@@ -825,7 +821,7 @@ func NewDualStackProxier(
 | 
			
		||||
		return nil, fmt.Errorf("unable to create ipv4 proxier: %v, hostname: %s, clusterCIDR : %s, nodeIP:%v", err, hostname, clusterCIDR, nodeIPs[v1.IPv4Protocol])
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ipv6Proxier, err := NewProxier(syncPeriod, minSyncPeriod,
 | 
			
		||||
	ipv6Proxier, err := NewProxier(v1.IPv6Protocol, syncPeriod, minSyncPeriod,
 | 
			
		||||
		clusterCIDR, hostname, nodeIPs[v1.IPv6Protocol], recorder, healthzServer,
 | 
			
		||||
		config, healthzPort)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -1455,7 +1451,7 @@ func (proxier *Proxier) syncProxyRules() {
 | 
			
		||||
			// Cluster IP LoadBalancer creation
 | 
			
		||||
			hnsLoadBalancer, err := hns.getLoadBalancer(
 | 
			
		||||
				clusterIPEndpoints,
 | 
			
		||||
				loadBalancerFlags{isDSR: proxier.isDSR, isIPv6: proxier.isIPv6Mode, sessionAffinity: sessionAffinityClientIP},
 | 
			
		||||
				loadBalancerFlags{isDSR: proxier.isDSR, isIPv6: proxier.ipFamily == v1.IPv6Protocol, sessionAffinity: sessionAffinityClientIP},
 | 
			
		||||
				sourceVip,
 | 
			
		||||
				svcInfo.ClusterIP().String(),
 | 
			
		||||
				Enum(svcInfo.Protocol()),
 | 
			
		||||
@@ -1490,7 +1486,7 @@ func (proxier *Proxier) syncProxyRules() {
 | 
			
		||||
				// If all endpoints are in terminating stage, then no need to create Node Port LoadBalancer
 | 
			
		||||
				hnsLoadBalancer, err := hns.getLoadBalancer(
 | 
			
		||||
					nodePortEndpoints,
 | 
			
		||||
					loadBalancerFlags{isVipExternalIP: true, isDSR: svcInfo.localTrafficDSR, localRoutedVIP: true, sessionAffinity: sessionAffinityClientIP, isIPv6: proxier.isIPv6Mode},
 | 
			
		||||
					loadBalancerFlags{isVipExternalIP: true, isDSR: svcInfo.localTrafficDSR, localRoutedVIP: true, sessionAffinity: sessionAffinityClientIP, isIPv6: proxier.ipFamily == v1.IPv6Protocol},
 | 
			
		||||
					sourceVip,
 | 
			
		||||
					"",
 | 
			
		||||
					Enum(svcInfo.Protocol()),
 | 
			
		||||
@@ -1525,7 +1521,7 @@ func (proxier *Proxier) syncProxyRules() {
 | 
			
		||||
				// Try loading existing policies, if already available
 | 
			
		||||
				hnsLoadBalancer, err = hns.getLoadBalancer(
 | 
			
		||||
					externalIPEndpoints,
 | 
			
		||||
					loadBalancerFlags{isVipExternalIP: true, isDSR: svcInfo.localTrafficDSR, sessionAffinity: sessionAffinityClientIP, isIPv6: proxier.isIPv6Mode},
 | 
			
		||||
					loadBalancerFlags{isVipExternalIP: true, isDSR: svcInfo.localTrafficDSR, sessionAffinity: sessionAffinityClientIP, isIPv6: proxier.ipFamily == v1.IPv6Protocol},
 | 
			
		||||
					sourceVip,
 | 
			
		||||
					externalIP.ip,
 | 
			
		||||
					Enum(svcInfo.Protocol()),
 | 
			
		||||
@@ -1556,7 +1552,7 @@ func (proxier *Proxier) syncProxyRules() {
 | 
			
		||||
			if len(lbIngressEndpoints) > 0 {
 | 
			
		||||
				hnsLoadBalancer, err := hns.getLoadBalancer(
 | 
			
		||||
					lbIngressEndpoints,
 | 
			
		||||
					loadBalancerFlags{isVipExternalIP: true, isDSR: svcInfo.preserveDIP || svcInfo.localTrafficDSR, useMUX: svcInfo.preserveDIP, preserveDIP: svcInfo.preserveDIP, sessionAffinity: sessionAffinityClientIP, isIPv6: proxier.isIPv6Mode},
 | 
			
		||||
					loadBalancerFlags{isVipExternalIP: true, isDSR: svcInfo.preserveDIP || svcInfo.localTrafficDSR, useMUX: svcInfo.preserveDIP, preserveDIP: svcInfo.preserveDIP, sessionAffinity: sessionAffinityClientIP, isIPv6: proxier.ipFamily == v1.IPv6Protocol},
 | 
			
		||||
					sourceVip,
 | 
			
		||||
					lbIngressIP.ip,
 | 
			
		||||
					Enum(svcInfo.Protocol()),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user