1

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.

jersey bean
  • 125
  • 1
  • 8

1 Answers1

1

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.

Shukant Pal
  • 103
  • 3
SYN
  • 1,751
  • 9
  • 14