大网数据广告活动
服务器运维问答

kubectl not showing new context created in GCP

· 52CE 我爱测

From client A, I created a new kubernetes cluster in GCP as follows: $ gcloud container clusters create my-new-cluster --num-nodes 3 From client A, I can see the new context was created: $ kubectl config get-contexts CURRENT NAME…

问题原文

原帖链接 · jersey bean · CC BY-SA 4.0

From client A, I created a new kubernetes cluster in GCP as follows:

$ gcloud container clusters create my-new-cluster --num-nodes 3

From client A, I can see the new context was created:

$ kubectl config get-contexts
CURRENT   NAME                                          CLUSTER                                       AUTHINFO                                      NAMESPACE
*         gke_learn-k8s-261120_us-west1-b_my-new-cluster   gke_learn-k8s-261120_us-west1-b_my-new-cluster   gke_learn-k8s-261120_us-west1-b_my-new-cluster   
          gke_learn-k8s-261120_us-west1-b_kubia         gke_learn-k8s-261120_us-west1-b_kubia         gke_learn-k8s-261120_us-west1-b_kubia         
          minikube                                      minikube                                      minikube        

But when I go over to client B and run 'kubectl config get-context', then I do not see the new context created:

$ kubectl config get-contexts
CURRENT   NAME                                    CLUSTER                                 AUTHINFO                                NAMESPACE
*         gke_learn-k8s-261120_us-west1-b_kubia   gke_learn-k8s-261120_us-west1-b_kubia   gke_learn-k8s-261120_us-west1-b_kubia   
          minikube                                minikube                                minikube     

I'm unable to find any documentation online on how to refresh or sync from GCP the client B with the latest clusters, nodes, pods, etc...

FWIW I'm also able to see the cluster from the GCP Platform through the browser.

Please help explain what is happening here and how client B is able to get the latest kubertnetes cluster from GCP.

已采纳解答

原帖链接 · SYN · CC BY-SA 4.0

The get-contexts command from kubectl only looks for clusters in your $HOME/.kube/config.

To add your new cluster in client B configuration, you will first have to use some gcloud container clusters get-credentials command.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-12-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。