Kubernetes GCE/GKE Kubectl:服务器没有';“没有资源类型”;服务“;
我在google容器引擎上有两个kubernetes集群,但分别位于不同的google帐户上(一个使用我公司的电子邮件,另一个使用我的个人电子邮件)。我试图从一个集群切换到另一个集群。我是这样做的:Kubernetes GCE/GKE Kubectl:服务器没有';“没有资源类型”;服务“;,kubernetes,google-compute-engine,gcloud,google-kubernetes-engine,kubectl,Kubernetes,Google Compute Engine,Gcloud,Google Kubernetes Engine,Kubectl,我在google容器引擎上有两个kubernetes集群,但分别位于不同的google帐户上(一个使用我公司的电子邮件,另一个使用我的个人电子邮件)。我试图从一个集群切换到另一个集群。我是这样做的: 使用我的其他电子邮件地址登录 $gcloud init 获取新的kubectl证书 gcloud容器群集获取凭据 测试以查看是否已连接到新群集 $kubectl获得采购订单 但是,我仍然无法获得集群中的kubernetes资源。我收到的错误是: 服务器没有资源类型“pods”发生这种情况是因为尽管我
$gcloud init
gcloud容器群集获取凭据
$kubectl获得采购订单
服务器没有资源类型“pods”
发生这种情况是因为尽管我使用新凭据登录。。。kubectl没有使用新的凭证。要更改kubectl用于访问群集的登录/访问凭据,您需要运行以下命令:
gcloud auth application-default login
然后您将得到以下响应:
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth
redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&prompt=select_account&respons
e_type=code&client_id=...&
scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email
+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&access_type=offline
Credentials saved to file: [/Users/.../.config/gcloud/application_default_credentials.json]
These credentials will be used by any library that requests
Application Default Credentials.
然后获取群集凭据
gcloud容器群集获取凭据[群集名称/id]
您现在应该能够使用kubectl访问集群。这是因为尽管我使用新凭据登录。。。kubectl没有使用新的凭证。要更改kubectl用于访问群集的登录/访问凭据,您需要运行以下命令:
gcloud auth application-default login
然后您将得到以下响应:
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth
redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&prompt=select_account&respons
e_type=code&client_id=...&
scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email
+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&access_type=offline
Credentials saved to file: [/Users/.../.config/gcloud/application_default_credentials.json]
These credentials will be used by any library that requests
Application Default Credentials.
然后获取群集凭据
gcloud容器群集获取凭据[群集名称/id]
您现在应该能够使用kubectl访问集群