| name | cluster-operations |
| type | skill |
| description | Day-2 cluster operations โ node management, etcd backup/restore, certificate rotation, namespace lifecycle. |
| related-rules | ["cluster-standards.md","upgrade-policy.md"] |
| allowed-tools | Read, Bash |
Skill: Cluster Operations
Expertise: Safe day-2 operations on self-hosted Kubernetes clusters โ node drain, etcd ops, cert rotation.
When to load
When draining nodes for maintenance, rotating certificates, backing up etcd, or troubleshooting control plane issues.
Node Lifecycle Operations
kubectl cordon <node-name>
kubectl drain <node-name> \
--ignore-daemonsets \
--delete-emptydir-data \
--grace-period=60 \
--timeout=300s
kubectl uncordon <node-name>
kubectl get pods -A --field-selector=spec.nodeName=<node-name>
etcd Backup (bare-metal / kubeadm)
ETCDCTL_API=3 etcdctl snapshot save /backup/etcd-$(date +%Y%m%d-%H%M%S).db \
--endpoints=https://127.0.0.1:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/healthcheck-client.crt \
--key=/etc/kubernetes/pki/etcd/healthcheck-client.key
ETCDCTL_API=3 etcdctl snapshot status /backup/etcd-latest.db --write-out=table
ETCDCTL_API=3 etcdctl snapshot restore /backup/etcd-latest.db \
--data-dir=/var/lib/etcd-restored \
--initial-cluster=master-1=https://192.168.1.10:2380 \
--initial-advertise-peer-urls=https://192.168.1.10:2380 \
--name=master-1
Certificate Rotation (kubeadm)
kubeadm certs check-expiration
kubeadm certs renew all
for pod in kube-apiserver kube-controller-manager kube-scheduler; do
kubectl -n kube-system delete pod -l component=$pod
done
cp /etc/kubernetes/admin.conf ~/.kube/config
Namespace Lifecycle
kubectl create namespace my-team-prod
kubectl label namespace my-team-prod \
environment=production \
team=my-team \
pod-security.kubernetes.io/enforce=restricted
kubectl apply -f infra/namespaces/defaults/ -n my-team-prod
kubectl get all -n <namespace-to-delete>
kubectl delete namespace <name>
kubectl get namespace <name> -o json | \
jq '.spec.finalizers = []' | \
kubectl replace --raw "/api/v1/namespaces/<name>/finalize" -f -
Control Plane Health Checks
kubectl get componentstatuses
kubectl get pods -n kube-system
ETCDCTL_API=3 etcdctl endpoint health \
--endpoints=https://127.0.0.1:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/healthcheck-client.crt \
--key=/etc/kubernetes/pki/etcd/healthcheck-client.key
kubectl describe nodes | grep -A5 "Conditions:"
Useful Aliases / One-liners
kubectl get pods -A --field-selector=status.phase!=Running,status.phase!=Succeeded
kubectl get events -n <ns> --sort-by='.lastTimestamp'
kubectl top pods -A --sort-by=memory | head -20
kubectl get pods -A -o wide | grep <node-name>