Working with Clusters
1. Creating Local Cluster
| Tool | Command | Best For |
| kind | kind create cluster --name dev | CI, multi-node testing |
| minikube | minikube start --driver=docker | Beginners, add-ons |
| k3d | k3d cluster create dev --agents 2 | Lightweight k3s |
| Docker Desktop | Settings → Kubernetes → Enable | Single-node dev |
2. Connecting to Remote Cluster
| Provider | Command |
| EKS | aws eks update-kubeconfig --name CLUSTER --region us-east-1 |
| GKE | gcloud container clusters get-credentials CLUSTER --zone Z |
| AKS | az aks get-credentials -g RG -n CLUSTER |
| Manual | kubectl config set-cluster ... / set-credentials / set-context |
3. Viewing Cluster Nodes
| Command | Output |
kubectl get nodes | List nodes + status |
kubectl get nodes -o wide | Adds IPs, OS, runtime |
kubectl get nodes --show-labels | Include labels |
kubectl get nodes -l role=worker | Filter by label |
4. Describing Node Details
| Section | Contains |
| Conditions | Ready, MemoryPressure, DiskPressure, PIDPressure |
| Capacity / Allocatable | CPU, memory, ephemeral-storage, pods |
| System Info | OS, kernel, container runtime, kubelet |
| Allocated resources | Sum of pod requests/limits |
| Non-terminated Pods | List of pods running on node |
kubectl describe node ip-10-0-1-23
5. Labeling Nodes
| Command | Action |
kubectl label node N1 disktype=ssd | Add label |
kubectl label node N1 disktype- | Remove label |
kubectl label node N1 disktype=hdd --overwrite | Update |
6. Tainting Nodes
| Effect | Behavior |
| NoSchedule | New pods without toleration not scheduled |
| PreferNoSchedule | Soft version of NoSchedule |
| NoExecute | Evicts existing pods without toleration |
kubectl taint nodes N1 gpu=true:NoSchedule
kubectl taint nodes N1 gpu- # remove
7. Cordoning Nodes
| Command | Effect |
kubectl cordon NODE | Mark unschedulable; existing pods stay |
| SchedulingDisabled | Status shown by kubectl get nodes |
8. Draining Nodes
| Flag | Use |
--ignore-daemonsets | Skip DaemonSet pods |
--delete-emptydir-data | Allow eviction with emptyDir |
--force | Evict unmanaged pods |
--grace-period=60 | Override pod terminationGracePeriodSeconds |
--timeout=5m | Max wait |
kubectl drain ip-10-0-1-23 --ignore-daemonsets --delete-emptydir-data
9. Uncordoning Nodes
| Command | Effect |
kubectl uncordon NODE | Re-enable scheduling after maintenance |
10. Checking Cluster Health
| Check | Command |
| API health | kubectl get --raw='/readyz?verbose' |
| Liveness | kubectl get --raw='/livez?verbose' |
| Node Ready | kubectl get nodes |
| Control plane pods | kubectl get pods -n kube-system |
| Events | kubectl get events -A --sort-by=.lastTimestamp |
11. Viewing API Resources
| Command | Output |
kubectl api-resources | List all resource types |
kubectl api-resources --namespaced=true | Namespaced only |
kubectl api-versions | List API groups/versions |
kubectl explain pod.spec.containers | Field documentation |
12. Managing Cluster Certificates
| Command | Action |
kubeadm certs check-expiration | Show cert expiry dates |
kubeadm certs renew all | Renew control-plane certs |
kubectl get csr | Pending CSRs |
kubectl certificate approve NAME | Approve CSR |
Warning: Certs auto-renew on kubeadm upgrade. Otherwise renew before 1-year expiry.