Remove some unused winkernel arguments/fields/functions

The winkernel proxy was originally created by copying+pasting from the
iptables code, but some iptables-specific things were never removed
(and one function got left behind after its functionality was moved
into the shared proxy code).
This commit is contained in:
Dan Winship 2023-03-14 15:18:22 -04:00
parent 8a790ac2e1
commit be101a748d
2 changed files with 6 additions and 42 deletions

View File

@ -111,8 +111,6 @@ func newProxyServer(config *proxyconfigapi.KubeProxyConfiguration, master string
proxier, err = winkernel.NewDualStackProxier( proxier, err = winkernel.NewDualStackProxier(
config.IPTables.SyncPeriod.Duration, config.IPTables.SyncPeriod.Duration,
config.IPTables.MinSyncPeriod.Duration, config.IPTables.MinSyncPeriod.Duration,
config.IPTables.MasqueradeAll,
int(*config.IPTables.MasqueradeBit),
config.ClusterCIDR, config.ClusterCIDR,
hostname, hostname,
nodeIPTuple(config.BindAddress), nodeIPTuple(config.BindAddress),
@ -125,8 +123,6 @@ func newProxyServer(config *proxyconfigapi.KubeProxyConfiguration, master string
proxier, err = winkernel.NewProxier( proxier, err = winkernel.NewProxier(
config.IPTables.SyncPeriod.Duration, config.IPTables.SyncPeriod.Duration,
config.IPTables.MinSyncPeriod.Duration, config.IPTables.MinSyncPeriod.Duration,
config.IPTables.MasqueradeAll,
int(*config.IPTables.MasqueradeBit),
config.ClusterCIDR, config.ClusterCIDR,
hostname, hostname,
nodeIP, nodeIP,

View File

@ -33,7 +33,6 @@ import (
"github.com/Microsoft/hcsshim/hcn" "github.com/Microsoft/hcsshim/hcn"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
discovery "k8s.io/api/discovery/v1" discovery "k8s.io/api/discovery/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/intstr"
apiutil "k8s.io/apimachinery/pkg/util/net" apiutil "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
@ -41,7 +40,6 @@ import (
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/tools/events" "k8s.io/client-go/tools/events"
"k8s.io/klog/v2" "k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
kubefeatures "k8s.io/kubernetes/pkg/features" kubefeatures "k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/proxy" "k8s.io/kubernetes/pkg/proxy"
"k8s.io/kubernetes/pkg/proxy/apis/config" "k8s.io/kubernetes/pkg/proxy/apis/config"
@ -614,21 +612,14 @@ type Proxier struct {
initialized int32 initialized int32
syncRunner *async.BoundedFrequencyRunner // governs calls to syncProxyRules syncRunner *async.BoundedFrequencyRunner // governs calls to syncProxyRules
// These are effectively const and do not need the mutex to be held. // These are effectively const and do not need the mutex to be held.
masqueradeAll bool clusterCIDR string
masqueradeMark string hostname string
clusterCIDR string nodeIP net.IP
hostname string recorder events.EventRecorder
nodeIP net.IP
recorder events.EventRecorder
serviceHealthServer healthcheck.ServiceHealthServer serviceHealthServer healthcheck.ServiceHealthServer
healthzServer healthcheck.ProxierHealthUpdater healthzServer healthcheck.ProxierHealthUpdater
// Since converting probabilities (floats) to strings is expensive
// and we are using only probabilities in the format of 1/n, we are
// precomputing some number of those and cache for future reuse.
precomputedProbabilities []string
hns HostNetworkService hns HostNetworkService
network hnsNetworkInfo network hnsNetworkInfo
sourceVip string sourceVip string
@ -677,8 +668,6 @@ var _ proxy.Provider = &Proxier{}
func NewProxier( func NewProxier(
syncPeriod time.Duration, syncPeriod time.Duration,
minSyncPeriod time.Duration, minSyncPeriod time.Duration,
masqueradeAll bool,
masqueradeBit int,
clusterCIDR string, clusterCIDR string,
hostname string, hostname string,
nodeIP net.IP, nodeIP net.IP,
@ -687,9 +676,6 @@ func NewProxier(
config config.KubeProxyWinkernelConfiguration, config config.KubeProxyWinkernelConfiguration,
healthzPort int, healthzPort int,
) (*Proxier, error) { ) (*Proxier, error) {
masqueradeValue := 1 << uint(masqueradeBit)
masqueradeMark := fmt.Sprintf("%#08x/%#08x", masqueradeValue, masqueradeValue)
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")
nodeIP = netutils.ParseIPSloppy("127.0.0.1") nodeIP = netutils.ParseIPSloppy("127.0.0.1")
@ -783,8 +769,6 @@ func NewProxier(
endPointsRefCount: make(endPointsReferenceCountMap), endPointsRefCount: make(endPointsReferenceCountMap),
svcPortMap: make(proxy.ServicePortMap), svcPortMap: make(proxy.ServicePortMap),
endpointsMap: make(proxy.EndpointsMap), endpointsMap: make(proxy.EndpointsMap),
masqueradeAll: masqueradeAll,
masqueradeMark: masqueradeMark,
clusterCIDR: clusterCIDR, clusterCIDR: clusterCIDR,
hostname: hostname, hostname: hostname,
nodeIP: nodeIP, nodeIP: nodeIP,
@ -822,8 +806,6 @@ func NewProxier(
func NewDualStackProxier( func NewDualStackProxier(
syncPeriod time.Duration, syncPeriod time.Duration,
minSyncPeriod time.Duration, minSyncPeriod time.Duration,
masqueradeAll bool,
masqueradeBit int,
clusterCIDR string, clusterCIDR string,
hostname string, hostname string,
nodeIP [2]net.IP, nodeIP [2]net.IP,
@ -834,14 +816,14 @@ func NewDualStackProxier(
) (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(syncPeriod, minSyncPeriod, masqueradeAll, masqueradeBit, ipv4Proxier, err := NewProxier(syncPeriod, minSyncPeriod,
clusterCIDR, hostname, nodeIP[0], recorder, healthzServer, config, healthzPort) clusterCIDR, hostname, nodeIP[0], recorder, healthzServer, config, healthzPort)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to create ipv4 proxier: %v, hostname: %s, clusterCIDR : %s, nodeIP:%v", err, hostname, clusterCIDR, nodeIP[0]) return nil, fmt.Errorf("unable to create ipv4 proxier: %v, hostname: %s, clusterCIDR : %s, nodeIP:%v", err, hostname, clusterCIDR, nodeIP[0])
} }
ipv6Proxier, err := NewProxier(syncPeriod, minSyncPeriod, masqueradeAll, masqueradeBit, ipv6Proxier, err := NewProxier(syncPeriod, minSyncPeriod,
clusterCIDR, hostname, nodeIP[1], recorder, healthzServer, config, healthzPort) clusterCIDR, hostname, nodeIP[1], recorder, healthzServer, config, healthzPort)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to create ipv6 proxier: %v, hostname: %s, clusterCIDR : %s, nodeIP:%v", err, hostname, clusterCIDR, nodeIP[1]) return nil, fmt.Errorf("unable to create ipv6 proxier: %v, hostname: %s, clusterCIDR : %s, nodeIP:%v", err, hostname, clusterCIDR, nodeIP[1])
@ -1034,20 +1016,6 @@ func (proxier *Proxier) OnServiceSynced() {
proxier.syncProxyRules() proxier.syncProxyRules()
} }
func shouldSkipService(svcName types.NamespacedName, service *v1.Service) bool {
// if ClusterIP is "None" or empty, skip proxying
if !helper.IsServiceIPSet(service) {
klog.V(3).InfoS("Skipping service due to clusterIP", "serviceName", svcName, "clusterIP", service.Spec.ClusterIP)
return true
}
// Even if ClusterIP is set, ServiceTypeExternalName services don't get proxied
if service.Spec.Type == v1.ServiceTypeExternalName {
klog.V(3).InfoS("Skipping service due to Type=ExternalName", "serviceName", svcName)
return true
}
return false
}
// OnEndpointSliceAdd is called whenever creation of a new endpoint slice object // OnEndpointSliceAdd is called whenever creation of a new endpoint slice object
// is observed. // is observed.
func (proxier *Proxier) OnEndpointSliceAdd(endpointSlice *discovery.EndpointSlice) { func (proxier *Proxier) OnEndpointSliceAdd(endpointSlice *discovery.EndpointSlice) {