Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set the KUBECONFIG envar with all YAML files in the specified folder.
#!/bin/sh
DEFAULT_CONTEXTS="$HOME/.kube/config"
if test -f "${DEFAULT_CONTEXTS}"
then
export KUBECONFIG="$DEFAULT_CONTEXTS"
fi
CUSTOM_CONTEXTS="$HOME/.kube/custom-contexts"
mkdir -p "${CUSTOM_CONTEXTS}"
OIFS="$IFS"
IFS=$'\n'
for file in `find "${CUSTOM_CONTEXTS}" -type f -name "*.yml" -or -name "*.yaml"`
do
export KUBECONFIG="$file:$KUBECONFIG"
done
IFS="$OIFS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.