Skip to content

Instantly share code, notes, and snippets.

@spinscale
Created February 19, 2024 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spinscale/31b2e9d971403c54be7bca8c9be5d40a to your computer and use it in GitHub Desktop.
Save spinscale/31b2e9d971403c54be7bca8c9be5d40a to your computer and use it in GitHub Desktop.
Switch default namespaces in k8s
function kubens() {
ns=$(kubectl get ns | awk '{ print $1 }' | grep -v '^NAME$' | fzf)
kubectl config set-context --current --namespace=$ns
}
@spinscale
Copy link
Author

t-rec-ezgif com-speed

@spinscale
Copy link
Author

Turns out kubectx ships with kubens doing exactly this - it's actually a slightly bigger shell script also using fzf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment