How do I get Cluster information with kubectl?
Managing a K8s cluster is not necessarily simple and knowing 'something' about the Cluster details such as where is the Control Plane and what APIs/Resources are available for use makes it, at least, somewhat easier.
Cluster Information
kubectl version
![](https://hestia.ghost.io/content/images/2024/01/image-39.png)
kubectl cluster-info
Purpose: Use this when looking for details about the larger components like the IP addresses of the Control Plane and CoreDNS.
![](https://hestia.ghost.io/content/images/2024/01/image-41.png)
- We can see the Control Plane is running at https://172.31.91.124:6443.
- The CoreDNS pod is running at https://172.31.91.124:6443 ..... /kube-dns:dns/proxy.
kubectl get nodes
Purpose: Will list the nodes (Control Plane and Worker Nodes) that make up the cluster.
![](https://hestia.ghost.io/content/images/2024/01/image-42.png)
- There are 4 nodes in this cluster: 1 Control Plane and 3 Workers.
- They are all Ready (i.e. they are turned on and have confirmed they are part of the cluster).
- The Version of K8s installed on each node is 1.26.
Cluster API Information
kubectl api-versions
Purpose: Lists the version of APIs that are available as part of the installed k8s software. We need to know which APIs can be used in our applications, otherwise the deployment could fail if the API version used is not supported anymore.
![](https://hestia.ghost.io/content/images/2024/01/image-43.png)
kubectl api-resources
Purpose: Knowing which resources are available for use and what their versions are can help with troubleshooting. Additionally, and for the author particularly, knowing the short form for various resources makes running imperative commands on the terminal easier.
Imagine always having to type out kubectl get deployments or kubectl get persistentvolumeclaims. It gets tedious (and its very easy to fat finger the spelling for longer terms) quickly. Instead we could use kubectl get deploy or kubectl get pvc to get the same information.
![](https://hestia.ghost.io/content/images/2024/01/image-44.png)
I write to remember and if in the process, I can help someone learn about Containers, Orchestration (Docker Compose, Kubernetes), GitOps, DevSecOps, VR/AR, Architecture, and Data Management, that is just icing on the cake.