Kubectl Switch Contexts <Quick>
Then it hit him.
kubectl port-forward service/payment-api 8080:80 -n payment-system Fast. Responsive. 20ms responses. Something was wrong—not with the code, but with his assumptions . kubectl switch contexts
CURRENT NAME CLUSTER NAMESPACE prod-us-east prod-cluster payment-system * staging-us-west staging-cluster payment-system dev-local dev-cluster default He was looking at . The alert was from production . Then it hit him
“Then why is the alert firing?” he whispered. kubectl switch contexts
# Show k8s context in prompt export PS1='\[\e[33m\](k8s: $(kubectl config current-context 2>/dev/null))\[\e[0m\] \w \$ ' He also created an alias he’d never forget:
He’d been debugging the wrong cluster for the last ten minutes.