Kubernetes Administration — Level by Level›Level 4 · Cheat sheet & self-check

Level 4 — Production · wrap-up

Cheat sheet & self-check

Every command from this section on one page.

22 · HA control plane & load balancing

Join more control-plane nodes

sudo kubeadm init phase upload-certs --upload-certsRe-upload control-plane certs; prints a new certificate key (valid 2 hours)
kubeadm token create --print-join-commandBase join command (append --control-plane --certificate-key <key>)
sudo kubeadm join <VIP>:6443 --token … --discovery-token-ca-cert-hash … --control-plane --certificate-key …Join as a control-plane node

Check HA health

kubectl get nodes -l node-role.kubernetes.io/control-planeAll control-plane nodes
kubectl get lease -n kube-system kube-scheduler kube-controller-managerWhich node currently holds each leader lease
etcdctl … endpoint status --cluster -w tableetcd members, leader and DB size
curl -k https://<VIP>:6443/readyzIs the API reachable through the load balancer?

23 · Resource management & QoS

See usage vs requests

kubectl top nodesReal CPU/memory usage per node (needs metrics-server)
kubectl top pods -A --sort-by=memoryHungriest pods
kubectl describe node <node> | grep -A10 'Allocated resources'Sum of requests and limits on a node
kubectl get pod <pod> -o jsonpath='{.status.qosClass}'A pod's QoS class

Namespace guard-rails

kubectl get limitrange,resourcequota -n <ns>Defaults and totals for a namespace
kubectl describe resourcequota -n <ns>Used vs hard limits

Units

cpu: 500mHalf a CPU core (1000m = 1 core)
memory: 256Mi256 mebibytes (Mi/Gi are powers of 2; M/G are powers of 10)

24 · Autoscaling

HPA

kubectl autoscale deployment web --cpu-percent=60 --min=2 --max=10Quick CPU-based HPA
kubectl get hpa -wWatch current vs target and replica count
kubectl describe hpa webConditions and scaling events (why it did or didn't scale)

Which autoscaler?

HPAMore or fewer pods, from CPU/memory/custom metrics
VPABigger or smaller requests per pod, from observed usage
Cluster AutoscalerMore or fewer nodes in existing node groups when pods are Pending
KarpenterLaunches right-sized nodes directly for Pending pods; consolidates
KEDAScales on events (queue length, Kafka lag, cron), including to zero

25 · Cluster lifecycle at scale

Fleet inventory

kubectl config get-contexts -o nameEvery cluster in your kubeconfig
kubectl --context <ctx> version -o json | jq -r .serverVersion.gitVersionOne cluster's server version
kubectl --context <ctx> get nodes -o custom-columns=NAME:.metadata.name,KUBELET:.status.nodeInfo.kubeletVersionKubelet versions per node

Pre-flight checks (per cluster)

kubectl get nodes | grep -v ' Ready'Anything not Ready?
kubectl get pods -A | grep -vE 'Running|Completed'Unhealthy pods before you start
kubectl get pdb -ABudgets that could block drains
kubectl get --raw /metrics | grep apiserver_requested_deprecated_apisDeprecated API usage
sudo kubeadm certs check-expirationCertificate expiry (kubeadm clusters)

26 · Performance tuning

Health and latency metrics

etcd_disk_wal_fsync_duration_secondsetcd write-ahead-log fsync latency (keep p99 low, ~10ms)
etcd_disk_backend_commit_duration_secondsetcd commit latency
apiserver_request_duration_secondsAPI latency by verb and resource
apiserver_flowcontrol_rejected_requests_totalRequests rejected by API Priority and Fairness

Inspect

kubectl get flowschemas,prioritylevelconfigurationsHow the API server prioritises clients
kubectl get --raw /metrics | grep apiserver_request_totalRequest counts by verb/resource/code
sudo cat /var/lib/kubelet/config.yamlThe kubelet's configuration (kubeadm nodes)

27 · Disaster recovery

Velero

velero backup create shop-$(date +%F) --include-namespaces shopBack up one namespace (objects + volumes as configured)
velero backup describe <backup> --detailsWhat was captured, warnings and errors
velero restore create --from-backup <backup>Restore it
velero schedule create daily-shop --schedule='0 2 * * *' --include-namespaces shop --ttl 720hNightly backup kept for 30 days
velero backup-location getIs the object storage target available?

Words to agree on

RPORecovery Point Objective: how much data you can afford to lose (time)
RTORecovery Time Objective: how long until service is back