Graduate EndpointSlice Controllers to GA

- EndpointSlice controller will stop writing to Topology field
 - EndpointSlice controller will only provide NodeName and Zone on
 EndpointSlices
This commit is contained in:
Swetha Repakula
2021-03-04 20:53:35 -08:00
parent f8151b121f
commit 1925d94b18
26 changed files with 170 additions and 298 deletions

View File

@@ -22,8 +22,7 @@ import (
"strings"
corev1 "k8s.io/api/core/v1"
discovery "k8s.io/api/discovery/v1beta1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
discovery "k8s.io/api/discovery/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -62,25 +61,6 @@ func getAddressType(address string) *discovery.AddressType {
return &addressType
}
// endpointsEqualBeyondHash returns true if endpoints have equal attributes
// but excludes equality checks that would have already been covered with
// endpoint hashing (see hashEndpoint func for more info).
func endpointsEqualBeyondHash(ep1, ep2 *discovery.Endpoint) bool {
if !apiequality.Semantic.DeepEqual(ep1.Topology, ep2.Topology) {
return false
}
if !boolPtrEqual(ep1.Conditions.Ready, ep2.Conditions.Ready) {
return false
}
if !objectRefPtrEqual(ep1.TargetRef, ep2.TargetRef) {
return false
}
return true
}
// newEndpointSlice returns an EndpointSlice generated from an Endpoints
// resource, ports, and address type.
func newEndpointSlice(endpoints *corev1.Endpoints, ports []discovery.EndpointPort, addrType discovery.AddressType, sliceName string) *discovery.EndpointSlice {
@@ -135,9 +115,6 @@ func addressToEndpoint(address corev1.EndpointAddress, ready bool) *discovery.En
}
if address.NodeName != nil {
endpoint.Topology = map[string]string{
"kubernetes.io/hostname": *address.NodeName,
}
endpoint.NodeName = address.NodeName
}
if address.Hostname != "" {
@@ -163,29 +140,6 @@ func epPortsToEpsPorts(epPorts []corev1.EndpointPort) []discovery.EndpointPort {
return epsPorts
}
// boolPtrEqual returns true if a set of bool pointers have equivalent values.
func boolPtrEqual(ptr1, ptr2 *bool) bool {
if (ptr1 == nil) != (ptr2 == nil) {
return false
}
if ptr1 != nil && ptr2 != nil && *ptr1 != *ptr2 {
return false
}
return true
}
// objectRefPtrEqual returns true if a set of object ref pointers have
// equivalent values.
func objectRefPtrEqual(ref1, ref2 *corev1.ObjectReference) bool {
if (ref1 == nil) != (ref2 == nil) {
return false
}
if ref1 != nil && ref2 != nil && !apiequality.Semantic.DeepEqual(*ref1, *ref2) {
return false
}
return true
}
// getServiceFromDeleteAction parses a Service resource from a delete
// action.
func getServiceFromDeleteAction(obj interface{}) *corev1.Service {