Search code examples
gcloudkubectl

How to remove warning in kubectl with gcp auth plugin?


When I run any kubectl command I get following WARNING:

W0517 14:33:54.147340   46871 gcp.go:120] WARNING: the gcp auth plugin is deprecated in v1.22+, unavailable in v1.25+; use gcloud instead.
To learn more, consult https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke

I have followed the instructions in the link several times but the WARNING keeps appearing making kubectl output uncomfortable to read.

OS:

cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"

kubectl version:

Client Version: v1.24.0
Kustomize Version: v4.5.4

gke-gcloud-auth-plugin:

Kubernetes v1.23.0-alpha+66064c62c6c23110c7a93faca5fba668018df732

gcloud version:

Google Cloud SDK 385.0.0
alpha 2022.05.06
beta 2022.05.06
bq 2.0.74
bundled-python3-unix 3.9.12
core 2022.05.06
gsutil 5.10

I "login" with:

gcloud init

and then:

gcloud container clusters get-credentials cluster_name --region my-region

finally:

myyser@mymachine:/$ k get pods -n madeupns
W0517 14:50:10.570103   50345 gcp.go:120] WARNING: the gcp auth plugin is deprecated in v1.22+, unavailable in v1.25+; use gcloud instead.
To learn more, consult https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
No resources found in madeupns namespace.

How can I remove the WARNING or fix the problem?

Removing my .kube/config and re-running get-credentials didn't work.


Solution

  • I fixed this problem by adding the correct export in .bashrc

    export USE_GKE_GCLOUD_AUTH_PLUGIN=True
    

    After sourcing .bashrc with . ~/.bashrc and reloading cluster config with:

    gcloud container clusters get-credentials clustername
    

    the warning dissapeared:

    user@laptop:/$ k get svc -A
    NAMESPACE     NAME                   TYPE           CLUSTER-IP     EXTERNAL-IP    
    kube-system   default-http-backend   NodePort       10.10.13.157   <none>         
    kube-system   kube-dns               ClusterIP      10.10.0.10     <none>         
    kube-system   kube-dns-upstream      ClusterIP      10.10.13.92    <none>         
    kube-system   metrics-server         ClusterIP      10.10.2.191    <none>