How to Check Cluster Info in Kubernetes Quickly
Use the
kubectl cluster-info command to see the Kubernetes cluster's master and service endpoints. For detailed configuration, use kubectl config view to check your current cluster context and settings.Syntax
The main commands to check Kubernetes cluster info are:
kubectl cluster-info: Shows the cluster master and service URLs.kubectl config view: Displays the kubeconfig file details including clusters, users, and contexts.kubectl config current-context: Shows the active cluster context you are connected to.
bash
kubectl cluster-info kubectl config view kubectl config current-context
Example
This example shows how to check your Kubernetes cluster info and current context.
bash
kubectl cluster-info kubectl config current-context
Output
Kubernetes control plane is running at https://192.168.99.100:8443
CoreDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
minikube
Common Pitfalls
Common mistakes when checking cluster info include:
- Running
kubectlwithout a configured kubeconfig file or context, which causes errors. - Assuming
kubectl cluster-infoshows node details; it only shows master and services info. - Not having access rights to the cluster, leading to permission denied errors.
bash
kubectl cluster-info # Wrong: No kubeconfig or context set kubectl config current-context # Right: Ensure kubeconfig is set and context is selected
Quick Reference
| Command | Description |
|---|---|
| kubectl cluster-info | Shows cluster master and service endpoints |
| kubectl config view | Displays full kubeconfig details |
| kubectl config current-context | Shows the active cluster context |
| kubectl get nodes | Lists all nodes in the cluster |
Key Takeaways
Use
kubectl cluster-info to quickly see cluster master and service URLs.Check your active cluster context with
kubectl config current-context.Ensure your kubeconfig file is properly set to avoid connection errors.
kubectl config view shows detailed cluster and user configuration.kubectl get nodes helps to see all nodes in your cluster.