I am a newbie to Google Kubernetes Engine (GKE), and I am trying to understand the object model behind it all with respect to clusters.
If I look at the clusters screen, I can see a list of my clusters :
But if I use the command line (kubectl), then I see something completely different :
Why are there two different types of cluster names? Which one is the correct cluster name?
Is it cluster-2 or gke_strange-vortex-286312_us-central1-c_cluster-2 ?
This is massively confusing.
Naming scheme of GKE
clusters found in $ kubectl config get-contexts
is following:
gke_PROJECT-ID_ZONE_CLUSTER-NAME
For example:
gke_AWESOME-PROJECT-123456_europe-west3-c_super-cluster
From the GCP
perspective the correct name is: super-cluster
.
You will need to use the name pointed in either (they are the same):
Cloud Console
(UI) $ gcloud container clusters list
For example:
$ gcloud container clusters get-credentials super-cluster --zone=europe-west3-c
).It's important to use
--zone=ZONE
as there can be clusters named the same in different zones/regions.
Above command will fetch the cluster endpoint and auth data. It will also set the ~/.kube/config
to target super-cluster
.
You don't need to use the gke_PROJECT-ID_europe-west3-c_super-cluster
unless you would like to change context (which cluster are you issuing commands to) with $ kubectl
and not $ gcloud
command
The naming scheme used in ~/.kube/config
is used to distinguish one cluster (contexts wise) from another.
Additional resources: