Skip to content

Instantly share code, notes, and snippets.

@Dirc
Created May 6, 2020 19:11
Show Gist options
  • Save Dirc/4596c8cfb757c7f457c4e0362f21e219 to your computer and use it in GitHub Desktop.
Save Dirc/4596c8cfb757c7f457c4e0362f21e219 to your computer and use it in GitHub Desktop.

Manage Kube Config

You need to delete contexts, clusters, users seperately.

kubectl config current-context

# Context
kubectl config get-contexts
kubectl config delete-context CONTEXT

# Clusters
kubectl config get-clusters
kubectl config delete-cluster CLUSTER
# Delete all
for i in $(kubectl config get-clusters); do kubectl config delete-cluster $i; done

# Users
kubectl config view -o jsonpath='{range .users[*]}{.name}{"\n"}{end}'
kubectl config unset users.NAME
# Delete all
for i in $(kubectl config view -o jsonpath='{range .users[*]}{.name}{"\n"}{end}'); do kubectl config unset users.$i; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment