🚀 New Features Now Live: DIBBS, Forecasts & More! Learn more here

    Change Context ((new)) | Kubectl

    But wait. That’s the production cluster name in the prompt. Your stomach drops. You just deployed a half-baked, debug-logging, "staging-only" image to the live environment.

    The terminal blinks. Then it whispers back: "deployment.apps/payment-gateway created." kubectl change context

    kubectl config use-context prod-eks-cluster Output: Switched to context "prod-eks-cluster". Boom. You’re now aiming every kubectl get pods , kubectl logs , and kubectl delete at production. The Pro Move: Know Your Battlefield Before you switch, always check where you are right now . Run: But wait

    | CURRENT | NAME | CLUSTER | NAMESPACE | |---------|--------------------|--------------------|-----------| | * | dev-local | kind-dev | default | | | staging-gcp | gke-staging | frontend | | | prod-aws | arn:aws:eks:... | prod | Here’s where most tutorials stop, but you shouldn’t. A context is actually a triple: (cluster, user, namespace) . You just deployed a half-baked

    alias kctx='kubectl config current-context' But the real power move is seeing everything you can switch to:

    To change your active cluster, you don't need to re-enter API keys, re-download certs, or pray to the cloud gods. You just run:

    Mastering the art of kubectl config use-context before you accidentally deploy your test app to the live cluster. Let me paint a picture. It’s 3:00 PM on a Tuesday. You’ve been debugging a tricky authentication bug in your staging environment for two hours. You finally fix it. You type kubectl apply -f deployment.yaml and hit Enter.