[feat]:update the kubernets.go fix npe (#4338)

Signed-off-by: Biao Jiang <standup-jb@github.com>

Co-authored-by: biao.jiang@ximalaya.com <biao.jiang@ximalaya.com>
This commit is contained in:
Jiang Biao 2020-12-16 19:31:34 +08:00 committed by GitHub
parent be955daa37
commit fc955fd166
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -252,7 +252,10 @@ 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, _ := kubeClient.ServerVersion()
sv, err := kubeClient.ServerVersion()
if err != nil {
return err
}
major, _ := strconv.Atoi(sv.Major)
minor, _ := strconv.Atoi(sv.Minor)
if k.opts.useEndpointSlices && major <= 1 && minor <= 18 {