I want to check the Kubernetes configuration – how many nodes, etc. I tried the following command.
kubectl describe cluster
error: the server doesn't have a resource type "cluster"
BTW, I tried to use the following command to check the AZ of the nodes of the pods. But it returns <none>
for all the pods’ nodes.
kubectl get pods -o=custom-columns=NAME:.metadata.name,ZONE:.metadata.labels.'topology.Kubernetes.io/zone'
How to use kubectl
to find the AZs of the pods?
3
Answers
Try this command
I could be missing the point of your question, but if you just need the nodes, you could do
kubectl get nodes
and then
kubectl describe node {node-name}
to get further details of an individual node
You could also combine the output from
kubectl get nodes
and either usejsonpath
orjq
to filter the information you need.Here are my nodes showing zone info(made up) in the cluster:
Using the
awk
command, the labeltopology.kubernetes.io/zone
is merged with the name of the pods scheduled on that particular node.NOTE: I have used lowercase
k
in the label keytopology.kubernetes.io/zone
; however, in your case, it’s uppercaseK
in the question. You might want to calibrate your command.PS: You can print
$1
in theawk
command to print the namespace, in case of filtering based on namespace is needed.