====== Contexts in kubernetes ====== ===== View configuration ===== $ kubectl config view apiVersion: v1 clusters: - cluster: certificate-authority-data: DATA+OMITTED server: https://kubernetes.docker.internal:6443 name: docker-desktop - cluster: certificate-authority-data: DATA+OMITTED server: https://192.168.100.10:6443 name: kubernetes contexts: - context: cluster: docker-desktop user: docker-desktop name: docker-desktop - context: cluster: docker-desktop user: docker-desktop name: docker-for-desktop - context: cluster: kubernetes user: kubernetes-admin name: kubernetes-admin@kubernetes current-context: docker-desktop kind: Config preferences: {} users: - name: docker-desktop user: client-certificate-data: REDACTED client-key-data: REDACTED - name: kubernetes-admin user: client-certificate-data: REDACTED client-key-data: REDACTED ===== List contexts ===== $ kubectl config get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE docker-desktop docker-desktop docker-desktop docker-for-desktop docker-desktop docker-desktop * kubernetes-admin@kubernetes kubernetes kubernetes-admin $ kubectl config current-context docker-desktop ===== Use/Active context ===== $ kubectl config get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE * docker-desktop docker-desktop docker-desktop erase-una-vez-k8s kubernetes kubernetes-admin $ kubectl config use-context erase-una-vez-k8s Switched to context "erase-una-vez-k8s". $ kubectl config get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE docker-desktop docker-desktop docker-desktop * erase-una-vez-k8s kubernetes kubernetes-admin ===== Delete context ===== $ kubectl config delete-context docker-for-desktop deleted context docker-for-desktop from /Users/rodolfo/.kube/config ==== Delete individual value ==== $ kubectl config unset contexts.[CONTEXT NAME] ===== Rename a context ==== $ kubectl config rename-context kubernetes-admin@kubernetes erase-una-vez-k8s Context "kubernetes-admin@kubernetes" renamed to "erase-una-vez-k8s".