Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove warning in kubectl with gcp auth plugin?

Tags:

kubectl

gcloud

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.

like image 482
Alexander Meise Avatar asked Aug 30 '25 14:08

Alexander Meise


2 Answers

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>         
like image 163
Alexander Meise Avatar answered Sep 14 '25 07:09

Alexander Meise


Got a similar issue, while connecting to a fresh Kubernetes cluster having a version v1.22.10-gke.600

gcloud container clusters get-credentials my-cluster --zone europe-west6-b --project project

and got the below error, as seems like now its become error for the newer version

Fetching cluster endpoint and auth data.
CRITICAL: ACTION REQUIRED: gke-gcloud-auth-plugin, which is needed for continued use of kubectl, was not found or is not executable. Install gke-gcloud-auth-plugin for use with kubectl by following https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke

enter image description here

fix that worked for me

gcloud components install gke-gcloud-auth-plugin
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
gcloud container clusters get-credentials my-cluster --zone europe-west6-b --project project

like image 40
Adiii Avatar answered Sep 14 '25 06:09

Adiii