You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows11下gke-gcloud-auth-plugin无法获取凭证的问题求助

Windows 11下Kubectl连接GKE集群遭遇gke-gcloud-auth-plugin认证失败

在Windows 11系统中尝试用Kubectl连接GKE集群时,遇到gke-gcloud-auth-plugin相关认证错误,已按官方指引操作但问题未解决。

执行kubectl get pods -n NAMESPACE等资源查看命令时,报错如下:

F0814 16:43:55.031825   15116 cred.go:145] print credential failed with error: Failed to retrieve access token:: error parsing gcloud output: invalid character '\x1b' looking for beginning of value
Unable to connect to the server: getting credentials: exec: executable gke-gcloud-auth-plugin.exe failed with exit code 1 

已完成的排查/操作

  1. 安装并验证gke-gcloud-auth-plugin
    通过gcloud components install gke-gcloud-auth-plugin安装插件,执行gcloud components list确认已安装:
$ gcloud components list

Your current Google Cloud CLI version is: 442.0.0
The latest available version is: 442.0.0

+----------------------------------------------------------------------------------------------------------------+
|                                                   Components                                                   |
+---------------+------------------------------------------------------+------------------------------+----------+
|     Status    |                         Name                         |              ID              |   Size   |
+---------------+------------------------------------------------------+------------------------------+----------+
| Not Installed | App Engine Go Extensions                             | app-engine-go                |  4.6 MiB |
| Not Installed | Appctl                                               | appctl                       | 18.7 MiB |
| Not Installed | Artifact Registry Go Module Package Helper           | package-go-module            |  < 1 MiB |
| Not Installed | Cloud Bigtable Command Line Tool                     | cbt                          | 11.4 MiB |
| Not Installed | Cloud Bigtable Emulator                              | bigtable                     |  7.0 MiB |
| Not Installed | Cloud Datastore Emulator                             | cloud-datastore-emulator     | 36.2 MiB |
| Not Installed | Cloud Firestore Emulator                             | cloud-firestore-emulator     | 42.5 MiB |
| Not Installed | Cloud Pub/Sub Emulator                               | pubsub-emulator              | 61.2 MiB |
| Not Installed | Cloud Run Proxy                                      | cloud-run-proxy              | 12.0 MiB |
| Not Installed | Cloud SQL Proxy                                      | cloud_sql_proxy              |  7.4 MiB |
| Not Installed | Google Container Registry's Docker credential helper | docker-credential-gcr        |  1.8 MiB |
| Not Installed | Log Streaming                                        | log-streaming                | 12.4 MiB |
| Not Installed | Minikube                                             | minikube                     | 34.5 MiB |
| Not Installed | Skaffold                                             | skaffold                     | 22.8 MiB |
| Not Installed | Terraform Tools                                      | terraform-tools              | 66.2 MiB |
| Not Installed | anthos-auth                                          | anthos-auth                  | 20.5 MiB |
| Not Installed | config-connector                                     | config-connector             | 56.9 MiB |
| Not Installed | enterprise-certificate-proxy                         | enterprise-certificate-proxy |  6.5 MiB |
| Not Installed | gcloud Alpha Commands                                | alpha                        |  < 1 MiB |
| Not Installed | gcloud Beta Commands                                 | beta                         |  < 1 MiB |
| Not Installed | gcloud app Java Extensions                           | app-engine-java              | 64.9 MiB |
| Not Installed | gcloud app PHP Extensions                            | app-engine-php               | 19.1 MiB |
| Not Installed | gcloud app Python Extensions                         | app-engine-python            |  8.5 MiB |
| Not Installed | gcloud app Python Extensions (Extra Libraries)       | app-engine-python-extras     | 27.3 MiB |
| Not Installed | kubectl                                              | kubectl                      |  < 1 MiB |
| Not Installed | kubectl-oidc                                         | kubectl-oidc                 | 20.5 MiB |
| Not Installed | pkg                                                  | pkg                          |          |
| Installed     | BigQuery Command Line Tool                           | bq                           |  1.6 MiB |
| Installed     | Cloud Storage Command Line Tool                      | gsutil                       | 11.3 MiB |
| Installed     | Google Cloud CLI Core Libraries                      | core                         | 21.4 MiB |
| Installed     | Google Cloud CRC32C Hash Tool                        | gcloud-crc32c                |  1.3 MiB |
| Installed     | gke-gcloud-auth-plugin                               | gke-gcloud-auth-plugin       |  8.0 MiB |
+---------------+------------------------------------------------------+------------------------------+----------+
To install or remove components at your current SDK version [442.0.0], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version [442.0.0], run:
  $ gcloud components update
  1. 获取集群凭证
    执行gcloud container clusters get-credentials CLUSTER_NAME --zone ZONE_NAME生成kubeconfig,相关配置片段如下:
- name: gke_MY_PROJECT_ID_MY_REGION_MY_CLUSTER_NAME
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      command: gke-gcloud-auth-plugin.exe
      installHint: Install gke-gcloud-auth-plugin for use with kubectl by following
        https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
      provideClusterInfo: true
  1. 环境变量与版本信息
  • 已设置系统环境变量USE_GKE_CLOUD_AUTH_PLUGIN=TRUE
  • 多次重装kubectl和gcloud,kubectl版本信息:
$ kubectl version
F0814 16:59:41.789555   37312 cred.go:145] print credential failed with error: Failed to retrieve access token:: error parsing gcloud output: invalid character '\x1b' looking for beginning of value
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.4", GitCommit:"fa3d7990104d7c1f16943a67f11b154b71f6a132", GitTreeState:"clean", BuildDate:"2023-07-19T12:20:54Z", GoVersion:"go1.20.6", Compiler:"gc", Platform:"windows/amd64"}
Kustomize Version: v5.0.1
Unable to connect to the server: getting credentials: exec: executable gke-gcloud-auth-plugin.exe failed with exit code 1
  • GCP控制台中集群版本为1.24.14-gke.1200

内容的提问来源于stack exchange,提问作者Eoin Molloy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 14:15:56