How via command line can I detect if a Kubernetes node is a master/control plane or not? Is there an environment variable I can check?
CodePudding user response:
You can use the kubectl get nodes -o wide
command to get a more detailed list of the nodes, containing the Roles column. There you can see that control-plane, master, etcd nodes have a special label.
CodePudding user response:
Kubernetes runs your workloads by placing containers into Pods to run on Nodes. A node may be a virtual or physical machine depending on the cluster. Each node is managed by the Control Plane and contains the services necessary to run Pods. You can try executing the command to get the details for the pod is a control plane or not,
You can use $ kubectl get nodes to list all nodes. Given by the roles control-plane or master you can identify the node. master will be replaced with control-plane in future releases.
If you would like to get Control Plane nodes use the command:
$ kubectl get nodes -l 'node-role.kubernetes.io/control-plane'
If you would like to get the master node use the command:
$ kubectl get nodes -l 'node-role.kubernetes.io/master'
If you need more information about your nodes you can run the command:
$ kubectl get nodes -o wide.
Please follow the documentation for more information on Control Place