Interview Prep/Kubernetes/Cluster operations: certs, drains, rollouts and quotas

`kubectl` against the right cluster suddenly shows resources from the wrong environment, and a teammate nearly deleted production.

BeginnerTroubleshootingCluster operations: certs, drains, rollouts and quotas
Answer

Likely causes → The current context or namespace in kubeconfig changed (merged kubeconfigs, KUBECONFIG env var pointing to several files, a script that ran kubectl config use-context).

Diagnose →

kubectl config current-context
kubectl config get-contexts
echo $KUBECONFIG

Fix → Switch to the intended context explicitly and always pass --context in scripts:

kubectl --context prod-eks -n payments get pods

Prevent → Prompt indicators (kube-ps1), separate kubeconfig files per environment, read-only default roles for humans in production, and admission policies that block deletion of protected namespaces.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Cluster operations: certs, drains, rollouts and quotas