当我运行任何 kubectl 命令时,我收到以下警告:
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
Run Code Online (Sandbox Code Playgroud)
我已按照链接中的说明多次操作,但警告不断出现,使 kubectl 输出难以阅读。
操作系统:
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
Run Code Online (Sandbox Code Playgroud)
kubectl 版本:
Client Version: v1.24.0
Kustomize Version: v4.5.4
Run Code Online (Sandbox Code Playgroud)
gke-gcloud-auth-插件:
Kubernetes v1.23.0-alpha+66064c62c6c23110c7a93faca5fba668018df732
Run Code Online (Sandbox Code Playgroud)
云版本:
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
Run Code Online (Sandbox Code Playgroud)
我“登录”:
gcloud init
Run Code Online (Sandbox Code Playgroud)
进而:
gcloud container clusters get-credentials cluster_name --region my-region
Run Code Online (Sandbox Code Playgroud)
最后:
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.
Run Code Online (Sandbox Code Playgroud)
如何删除警告或解决问题?
删除我的.kube/config
并重新运行 get-credentials 不起作用。
Ale*_*ise 45
我通过添加正确的导出解决了这个问题.bashrc
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
Run Code Online (Sandbox Code Playgroud)
.bashrc
使用以下命令获取并. ~/.bashrc
重新加载集群配置后:
gcloud container clusters get-credentials clustername
Run Code Online (Sandbox Code Playgroud)
警告消失了:
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>
Run Code Online (Sandbox Code Playgroud)
Adi*_*iii 10
在连接到具有版本的新 Kubernetes 集群时遇到类似的问题v1.22.10-gke.600
gcloud container clusters get-credentials my-cluster --zone europe-west6-b --project project
Run Code Online (Sandbox Code Playgroud)
并得到以下错误,现在看来它成为新版本的错误
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
Run Code Online (Sandbox Code Playgroud)
修复对我有用的
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
Run Code Online (Sandbox Code Playgroud)
Jit*_*hor 10
您需要执行以下操作来避免出现此警告消息并避免将来出现错误。
在 .bashrc 中添加正确的导出。我使用 .zshrc 而不是 .bashrc 因此在 .zshrc 中添加了导出
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
Run Code Online (Sandbox Code Playgroud)
重新加载.bashrc
source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
将 gcloud 更新到最新版本。
gcloud components update
Run Code Online (Sandbox Code Playgroud)
运行以下命令。将 CLUSTER_NAME 替换为您的集群的名称。这将强制该集群的 kubeconfig 更新为 Client-go Credential Plugin 配置。
gcloud container clusters get-credentials CLUSTER_NAME
Run Code Online (Sandbox Code Playgroud)
输入以下命令检查 kubeconfig 文件。现在您应该能够检测到 Root/Home 目录中 users 部分的 kubeconfig 文件中的更改(gke-gcloud-auth-plugin)
cat ~/.kube/config
Run Code Online (Sandbox Code Playgroud)
这背后的原因是:
kubectl 从 v1.26 版本开始将不再具有内置的 GKE 身份验证机制。因此GKE用户将需要下载并使用单独的身份验证插件来生成GKE特定的令牌以支持GKE的身份验证。要了解更多详细信息,请阅读此处。
归档时间: |
|
查看次数: |
31916 次 |
最近记录: |