Basic cluster operations
Basic Kubernetes cluster operations
Check the Kubernets cluster status
Get a list of Kubernetes cluster nodes:
kubectl get nodes
Run the previous command again with a new -o wide
option and compare the outputs:
kubectl get nodes -o wide
Check the description of the control plane node cp1
:
kubectl describe node cp1
Check the description for the node worker1
:
kubectl describe node worker1
Change a role description for nodes
Show labels for nodes:
kubectl get nodes --show-labels
Change the role name for data plane nodes:
kubectl label node worker1 node-role.kubernetes.io/worker=
kubectl label node worker2 node-role.kubernetes.io/worker=
or use a simple script to make this change for all workers:
for SRV in worker{1,2,3}; do
kubectl label node $SRV node-role.kubernetes.io/worker=
done
Check nodes labels:
kubectl get nodes
kubectl get nodes --show-labels
Configure node taints and cordons
Check node taints for a cluster:
kubectl describe nodes | grep Taints
Disable scheduling for worker1
:
kubectl taint node worker1 node-role.kubernetes.io/worker=:NoSchedule
Check the node taints once again:
kubectl describe nodes | grep Taints
Check the cluster status:
kubectl get nodes
Remove the node taint from worker1
:
kubectl taint node worker1 node-role.kubernetes.io/worker-
Repeat this operation, but this time use the cordon
subcommand:
kubectl cordon worker1
kubectl describe nodes | grep Taints
kubectl get nodes
Revert changes:
kubectl uncordon worker1
Annotate nodes
Annotate the cp1
node:
kubectl annotate node cp1 description="This is Kubernetes control plane node!"
Check the section of annotations:
kubectl describe node cp1
Remove the annotation:
kubectl annotate node cp1 description-