Updating EndpointSliceMirroring controller to copy labels from Endpoints
The KEP specifies that the controller will "mirror all labels from the Endpoints resource and all endpoints and ports from the corresponding subset". I'd missed that in my initial implementation, this should fix that.
This commit is contained in:
@@ -88,10 +88,7 @@ func newEndpointSlice(endpoints *corev1.Endpoints, ports []discovery.EndpointPor
|
||||
ownerRef := metav1.NewControllerRef(endpoints, gvk)
|
||||
epSlice := &discovery.EndpointSlice{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
discovery.LabelServiceName: endpoints.Name,
|
||||
discovery.LabelManagedBy: controllerName,
|
||||
},
|
||||
Labels: map[string]string{},
|
||||
OwnerReferences: []metav1.OwnerReference{*ownerRef},
|
||||
Namespace: endpoints.Namespace,
|
||||
},
|
||||
@@ -100,6 +97,13 @@ func newEndpointSlice(endpoints *corev1.Endpoints, ports []discovery.EndpointPor
|
||||
Endpoints: []discovery.Endpoint{},
|
||||
}
|
||||
|
||||
for label, val := range endpoints.Labels {
|
||||
epSlice.Labels[label] = val
|
||||
}
|
||||
|
||||
epSlice.Labels[discovery.LabelServiceName] = endpoints.Name
|
||||
epSlice.Labels[discovery.LabelManagedBy] = controllerName
|
||||
|
||||
if sliceName == "" {
|
||||
epSlice.GenerateName = getEndpointSlicePrefix(endpoints.Name)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user