简体   繁体   English

kubectl 正在尝试连接到 gcloud 而不是 docker 桌面

[英]kubectl is trying to connect to gcloud instead of docker desktop

My kubectl is connecting to GCP by default.我的 kubectl 默认连接到 GCP。 I was trying few changes locally and deploying to Docker Desktop Kube.netes.我尝试在本地进行一些更改并部署到 Docker Desktop Kube.netes。

I remember it was working earlier.我记得它早些时候工作过。 But recently when this is executed:但是最近执行此操作时:

kubectl get pods

It gives-它给-

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

Any clue how to fix this kubectl error and let it show Kube.netes stuffs from Docker Desktop also.关于如何修复此 kubectl 错误并让它显示来自 Docker 桌面的 Kube.netes 内容的任何线索。

You need to install the gke-gcloud-auth-plugin to avoid this warning now and in the future to avoid errors.您需要安装gke-gcloud-auth-plugin以避免现在和将来出现此警告以避免错误。

The easiest way to install the plugin is as follows:安装插件的最简单方法如下:

1- Update your Google Cloud SDK 1-更新您的谷歌云 SDK

gcloud components update

2- Install the plugin (if not already installed with the update) 2-安装插件(如果尚未安装更新)

gcloud components install gke-gcloud-auth-plugin

Story behind this:这背后的故事:

kubectl starting from version 1.25 will no longer have a built-in authentication mechanism for GKE and instead, you will have to install the mentioned plugin for kubectl to support authentication of GKE .1.25版本开始的kubectl将不再具有GKE的内置身份验证机制,相反,您必须为kubectl安装上述插件以支持GKE的身份验证。 Read the full details here .此处阅读完整的详细信息。

I was able to solve it by switching the context to docker-desktop .我能够通过将上下文切换到docker-desktop来解决它。 Now it shows from Docker Desktop Kubernetes instead connecting to GCP.现在它从 Docker 桌面 Kubernetes 显示,而不是连接到 GCP。

kubectl config use-context docker-desktop

To avoid this warning message basically, you need to export gke gcloud auth plugin in.bashrc file要基本上避免此警告消息,您需要在 .bashrc 文件中导出 gke gcloud auth 插件

export USE_GKE_GCLOUD_AUTH_PLUGIN=True

Added answer in details please visit here详细添加答案请访问此处

It's your kubectl active context, you can use docker-desktop as your active context:这是你的 kubectl 活动上下文,你可以使用 docker docker-desktop作为你的活动上下文:

kubectl config use-context docker-desktop

You can also see other existing contexts您还可以查看其他现有上下文

kubectl config get-contexts

And switch to them:并切换到他们:

kubectl config use-context <context-name>

This answer might be helpful.这个答案可能会有所帮助。

You can also run command below for more information:您还可以运行以下命令以获取更多信息:

kubectl config -h

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM