Last active
February 17, 2021 05:44
-
-
Save asabirov/8869de35f577b95f22788fecf1ac1754 to your computer and use it in GitHub Desktop.
Use multiple kube config files for kubectl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
DEFAULT_KUBECONFIG_FILE="$HOME/.kube/config" | |
if test -f "${DEFAULT_KUBECONFIG_FILE}" | |
then | |
export KUBECONFIG="$DEFAULT_KUBECONFIG_FILE" | |
fi | |
# Your additional kubeconfig files should be inside ~/.kube/configs | |
ADD_KUBECONFIG_FILES="$HOME/.kube/configs" | |
mkdir -p "${ADD_KUBECONFIG_FILES}" | |
OIFS="$IFS" | |
IFS=$'\n' | |
for kubeconfigFile in `find "${ADD_KUBECONFIG_FILES}" -type f -name "*.yml" -o -name "*.yaml"` | |
do | |
export KUBECONFIG="$kubeconfigFile:$KUBECONFIG" | |
done | |
IFS="$OIFS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source ./load-configs