To administrate a Kubernetes cluster locally on bare metal hardware is not always easy. You have to always remember every command for different tasks or look it up while your thoughts are on how to fix stuff and not how to write the command correctly.
To make this "look up the right command" easy, here is a small cheat sheet with the most important commands I personally use on my cluster:
Cluster operations
bash
1234567891011121314151617
# simple cluster endpoint information about services and master nodekubectl cluster-info# show Kubernetes version on client and serverkubectl version# show configuration file of the clusterkubectl config view# show all resources of a specific namespacekubectl get all -n NAMESPACE# show all resources over all namespaceskubectl get all -A# show all resources of the cluster in a CLI GUI with k9sk9s
Node operations
bash
1234567891011121314151617
# show all cluster nodeskubectl get nodes# annotate a node with a tagkubectl annotate node NODE_NAME KEY = VALUE# label a nodekubectl label node NODE_NAME LABEL = VALUE# mark node as schedulablekubectl uncordon node NODE_NAME# mark node as unschedulablekubectl cordon node NODE_NAME# drain a node in preperation for maintenancekubectl drain node NODE_NAME
Pod operations
bash
1234567891011
# show all pods with wider informationskubectl get pods -o wide -n NAMESPACE# show all pods over all namespaceskubectl get pods -A# describe deployment of podkubectl describe POD_NAME -n NAMESPACE# log into pod shellkubectl exec -it POD_NAME -n NAMESPACE -- /bin/bash # or /bin/sh