Commit c2028e33 authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

plugin/kubernetes: don't return when ServerVersion return an error (#4490)

When err=nil try to determine the version of the k8s cluster and disable
endpoint slices. Don't return from connecting to the cluster.

In the future we should just default to true, and delete all this code.
Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
parent 4843cdfe
......@@ -252,15 +252,14 @@ func (k *Kubernetes) InitKubeCache(ctx context.Context) (err error) {
}
// Disable use of endpoint slices for k8s versions 1.18 and earlier. Endpoint slices were
// introduced in 1.17 but EndpointSliceMirroring was not added until 1.19.
sv, err := kubeClient.ServerVersion()
if err != nil {
return err
}
major, _ := strconv.Atoi(sv.Major)
minor, _ := strconv.Atoi(strings.TrimRight(sv.Minor, "+"))
if k.opts.useEndpointSlices && major <= 1 && minor <= 18 {
log.Info("watching Endpoints instead of EndpointSlices in k8s versions < 1.19")
k.opts.useEndpointSlices = false
// if err != nil, we continue with the above default which is to use endpoint slices.
if sv, err := kubeClient.ServerVersion(); err == nil {
major, _ := strconv.Atoi(sv.Major)
minor, _ := strconv.Atoi(strings.TrimRight(sv.Minor, "+"))
if k.opts.useEndpointSlices && major <= 1 && minor <= 18 {
log.Info("Watching Endpoints instead of EndpointSlices in k8s versions < 1.19")
k.opts.useEndpointSlices = false
}
}
k.APIConn = newdnsController(ctx, kubeClient, k.opts)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment