LinuxCommandLibrary

kubectl-config

Manage Kubernetes configuration (kubeconfig) files for accessing clusters via `kubectl` or the Kubernetes API.

TLDR

Get all contexts in the default kubeconfig file

$ kubectl config get-contexts
copy


Get all clusters/contexts/users in a custom kubeconfig file
$ kubectl config [get-clusters|get-contexts|get-users] --kubeconfig [path/to/kubeconfig.yaml]
copy


Get the current context
$ kubectl config current-context
copy


Switch to another context
$ kubectl config [use|use-context] [context_name]
copy


Delete clusters/contexts/users
$ kubectl config [delete-cluster|delete-context|delete-user] [cluster|context|user]
copy


Permanently add custom kubeconfig files
$ export KUBECONFIG="[$HOME.kube/config:path/to/custom/kubeconfig.yaml]" kubectl config get-contexts
copy

Copied to clipboard