Switch to a different context

Kubernetes Commands & Best Practices Curriculum · 3:08

Listen on 93

Lyrics

[Verse 1]
When you're working with your clusters
And you need to make a switch
From development to staging
There's a command that does the trick
Your config holds the contexts
Like different doors to walk through
But you can only use one at a time
So here's what you should do

[Chorus]
Use context, switch it up
kubectl config use dash context
Pick the name and fire it up
kubectl config use dash context
When you need to change your view
To a different cluster too
Use context, that's the way
To switch where kubectl will play

[Verse 2]
Every context is a gateway
To a specific cluster space
With its own authentication
And its own namespace place
Before you run your pod commands
Or check your service state
Make sure you're in the right context
Don't let confusion be your fate

[Chorus]
Use context, switch it up
kubectl config use dash context
Pick the name and fire it up
kubectl config use dash context
When you need to change your view
To a different cluster too
Use context, that's the way
To switch where kubectl will play

[Bridge]
First list them with get dash contexts
See all the options there
Then choose the one you're targeting
Handle switching with care
Production, staging, local dev
Each context has its role
One command line will take you there
And give you full control

[Chorus]
Use context, switch it up
kubectl config use dash context
Pick the name and fire it up
kubectl config use dash context
When you need to change your view
To a different cluster too
Use context, that's the way
To switch where kubectl will play

[Outro]
Context switching made simple
Just remember the command
kubectl config use dash context
And you'll have control in hand

← Set a default namespace for your current context | List all contexts (clusters you can connect to) →