How can you speed up switching between namespaces using kubectl?

Experience Level: Medior
Tags: Kubernetes

Answer

Option 1:

Create alias and variable:

alias k=kubectl
    export n="config set-context --current --namespace"

Then switch namespace like this:

k $n=default

Option 2:

Create two aliases

alias k=kubectl
alias kn="kubectl config set-context --current --namespace"

Then switch namespace like this:

kn default
Kubernetes Certified Application Developer (CKAD) preparation
Kubernetes Certified Application Developer (CKAD) preparation

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself
Kubernetes
Kubernetes

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself
25 Kubernetes questions that will help you get certified and become more efficient with K8s
25 Kubernetes questions that will help you get certified and become more efficient with K8s

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself