kubectl 1.37 reference · Access and Configuration
kubectl config Command (kubectl)
Inspect and switch kubeconfig contexts (cluster, user and default namespace), and set the namespace for the current context.
kubectl 1.37
Syntax
kubectl config get-contexts | current-context | use-context NAME | set-context --current --namespace=NS
Parameters
| Parameter | Description |
|---|---|
get-contexts |
List contexts. |
use-context NAME |
Switch cluster/user. |
set-context --current --namespace=NS |
Change the default namespace. |
Examples
kubectl config current-context
kubectl config get-contexts -o name
Output
kind-rc-docs kind-rc-docs
Run this on your computer — see “Get Started” for setup.
kubectl config view --minify -o jsonpath='cluster: {.clusters[0].name}, user: {.users[0].name}{"\n"}'
Output
cluster: kind-rc-docs, user: kind-rc-docs
Run this on your computer — see “Get Started” for setup.
Many accidents are commands run against the wrong cluster: show the context in your shell prompt and use separate kubeconfig files for production.
Related
kubectl auth can-i· Check whether you, or another user or service account via --as, may perform an action; --list shows everything allowed.- kubectl Essentials · tutorial