Updating apiserver Endpoints management to set skip-mirror label

This will ensure that the self-referential kubernetes Endpoints
resources is not mirrored by the EndpointSliceMirroring controller.
This commit is contained in:
Rob Scott
2020-06-26 16:16:06 -07:00
parent 8691466059
commit 0695896caa
6 changed files with 136 additions and 69 deletions

View File

@@ -193,3 +193,17 @@ func allAddressesIPv6(addresses []corev1.EndpointAddress) bool {
return true
}
// setSkipMirrorTrue sets endpointslice.kubernetes.io/skip-mirror to true. It
// returns true if this has resulted in a change to the Endpoints resource.
func setSkipMirrorTrue(e *corev1.Endpoints) bool {
skipMirrorVal, ok := e.Labels[discovery.LabelSkipMirror]
if !ok || skipMirrorVal != "true" {
if e.Labels == nil {
e.Labels = map[string]string{}
}
e.Labels[discovery.LabelSkipMirror] = "true"
return true
}
return false
}