Find the Name of a Kubernetes Cluster

Finding the Name of a Kubernetes Cluster

To determine your Kubernetes cluster’s name, the kubectl command-line tool is your go-to solution, assuming it’s already installed and set up for your cluster. Run the following command to reveal the name of the cluster currently in use:

kubectl config current-context

This command displays the active cluster’s name as specified in your kubeconfig file, for example:


Exploring Environment Variables: Kubernetes automatically sets various environment variables that hold details about the current cluster. You can uncover the cluster name by checking the KUBERNETES_SERVICE_HOST or KUBERNETES_SERVICE_NAME variables:



Utilizing the Kubernetes Dashboard: The Kubernetes dashboard is another avenue where the cluster’s name is prominently displayed at the top of the dashboard, providing a graphical interface for cluster information.

Consulting Your Cloud Provider’s Console: For clusters deployed on cloud platforms like AWS, Google Cloud, or Azure, the cluster name can often be found in the cloud provider’s console or through their CLI tools. For instance:

  • Name: my-kubernetes-cluster
  • ARN: arn:aws:eks:us-west-2:123456789012:cluster/my-kubernetes-cluster

Inspecting Configuration Files: Access to your Kubernetes cluster’s configuration files also means you can find the cluster name in the kubeconfig file. This YAML file details the cluster, including its name, endpoint, and credentials.

code –

apiVersion: v1
- name: my-kubernetes-cluster
    server: https://
- name: my-context
    cluster: my-kubernetes-cluster
    user: my-user
current-context: my-context
kind: Config
preferences: {}
- name: my-user

If none of these works, try Kubectx

Kubectx simplifies switching between clusters and namespaces. It provides a user-friendly alternative to managing contexts and namespaces compared to kubectl.

There is a great tool called kubectx

kubectx – lists all previously added clusters and highlights the currently used one. This is only one word to type instead of kubectl config current-context.

kubectx <cluster> – switches to a chosen cluster.

Moreover this tool comes also with kubens which does exactly the same for namespaces:

kubens – lists all namespaces and shows the current one,

kubens <namespace> – switches to a chosen namespace.

In Conclusion:

Several methods exist to find your Kubernetes cluster’s name, depending on your environment and the tools at your disposal. Whether through command-line utilities, environment variables, the Kubernetes dashboard, cloud provider consoles, or direct inspection of configuration files, you have a range of options to identify your cluster.

More from this stream