Kubeproxy uses V1 EndpointSlice
This commit is contained in:
@@ -24,7 +24,7 @@ import (
|
||||
"sync"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
discovery "k8s.io/api/discovery/v1beta1"
|
||||
discovery "k8s.io/api/discovery/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
@@ -76,11 +76,11 @@ type endpointSliceInfo struct {
|
||||
|
||||
// endpointInfo contains just the attributes kube-proxy cares about.
|
||||
// Used for caching. Intentionally small to limit memory util.
|
||||
// Addresses and Topology are copied from EndpointSlice Endpoints.
|
||||
// Addresses, NodeName, and Zone are copied from EndpointSlice Endpoints.
|
||||
type endpointInfo struct {
|
||||
Addresses []string
|
||||
NodeName *string
|
||||
Topology map[string]string
|
||||
Zone *string
|
||||
ZoneHints sets.String
|
||||
|
||||
Ready bool
|
||||
@@ -130,7 +130,8 @@ func newEndpointSliceInfo(endpointSlice *discovery.EndpointSlice, remove bool) *
|
||||
for _, endpoint := range endpointSlice.Endpoints {
|
||||
epInfo := &endpointInfo{
|
||||
Addresses: endpoint.Addresses,
|
||||
Topology: endpoint.Topology,
|
||||
Zone: endpoint.Zone,
|
||||
NodeName: endpoint.NodeName,
|
||||
|
||||
// conditions
|
||||
Ready: endpoint.Conditions.Ready == nil || *endpoint.Conditions.Ready,
|
||||
@@ -138,8 +139,6 @@ func newEndpointSliceInfo(endpointSlice *discovery.EndpointSlice, remove bool) *
|
||||
Terminating: endpoint.Conditions.Terminating != nil && *endpoint.Conditions.Terminating,
|
||||
}
|
||||
|
||||
epInfo.NodeName = endpoint.NodeName
|
||||
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.TopologyAwareHints) {
|
||||
if endpoint.Hints != nil && len(endpoint.Hints.ForZones) > 0 {
|
||||
epInfo.ZoneHints = sets.String{}
|
||||
@@ -281,13 +280,18 @@ func (cache *EndpointSliceCache) addEndpoints(serviceNN types.NamespacedName, po
|
||||
}
|
||||
|
||||
isLocal := false
|
||||
nodeName := ""
|
||||
if endpoint.NodeName != nil {
|
||||
isLocal = cache.isLocal(*endpoint.NodeName)
|
||||
} else {
|
||||
isLocal = cache.isLocal(endpoint.Topology[v1.LabelHostname])
|
||||
nodeName = *endpoint.NodeName
|
||||
}
|
||||
|
||||
endpointInfo := newBaseEndpointInfo(endpoint.Addresses[0], portNum, isLocal, endpoint.Topology,
|
||||
zone := ""
|
||||
if endpoint.Zone != nil {
|
||||
zone = *endpoint.Zone
|
||||
}
|
||||
|
||||
endpointInfo := newBaseEndpointInfo(endpoint.Addresses[0], nodeName, zone, portNum, isLocal,
|
||||
endpoint.Ready, endpoint.Serving, endpoint.Terminating, endpoint.ZoneHints)
|
||||
|
||||
// This logic ensures we're deduplicating potential overlapping endpoints
|
||||
|
||||
Reference in New Issue
Block a user