Skip to content

Instantly share code, notes, and snippets.

@mjpitz
Last active December 1, 2020 15:00
Show Gist options
  • Save mjpitz/18e0b946b803e344bd16495316e40fa3 to your computer and use it in GitHub Desktop.
Save mjpitz/18e0b946b803e344bd16495316e40fa3 to your computer and use it in GitHub Desktop.
One-line dynamic KUBECONFIG per shell
# Enables each Shell instance to have their own KUBECONFIG.
# Also aggregates all cluster contexts into a single configuration.
# Simply add to .bashrc or .bash_profile
kubeconfig="${KUBECONFIG}"
if [[ -z "${kubeconfig}" ]]; then
kubeconfig="$(mktemp):$(ls -1 ${HOME}/.kube/*.yaml | tr $'\n' ':')${HOME}/.kube/config"
fi
export KUBECONFIG="${kubeconfig}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment