Updating kube-proxy to support new EndpointSlice address types

This includes IPv4 and IPv6 address types and IPVS dual stack support.
Importantly this ensures that EndpointSlices with a FQDN address type
are not processed by kube-proxy.
This commit is contained in:
Rob Scott
2019-11-13 14:59:15 -08:00
parent c466fd9eaf
commit 2a021d02c9
3 changed files with 53 additions and 5 deletions

View File

@@ -35,6 +35,12 @@ import (
utilnet "k8s.io/utils/net"
)
var supportedEndpointSliceAddressTypes = sets.NewString(
string(discovery.AddressTypeIP), // IP is a deprecated address type
string(discovery.AddressTypeIPv4),
string(discovery.AddressTypeIPv6),
)
// BaseEndpointInfo contains base information that defines an endpoint.
// This could be used directly by proxier while processing endpoints,
// or can be used for constructing a more specific EndpointInfo struct
@@ -173,6 +179,11 @@ func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool {
// It returns true if items changed, otherwise return false. Will add/update/delete items of EndpointsChangeMap.
// If removeSlice is true, slice will be removed, otherwise it will be added or updated.
func (ect *EndpointChangeTracker) EndpointSliceUpdate(endpointSlice *discovery.EndpointSlice, removeSlice bool) bool {
if !supportedEndpointSliceAddressTypes.Has(string(endpointSlice.AddressType)) {
klog.V(4).Infof("EndpointSlice address type not supported by kube-proxy: %s", endpointSlice.AddressType)
return false
}
// This should never happen
if endpointSlice == nil {
klog.Error("Nil endpointSlice passed to EndpointSliceUpdate")