Created
May 28, 2021 01:44
-
-
Save kumakichi/32bc9f47ccfd69bc3094253a8303ffb0 to your computer and use it in GitHub Desktop.
merge multiple kubernetes configs
This file contains hidden or 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
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 kubeconfigs-path" | |
exit | |
fi | |
kubeCfgPath="$1" | |
if [ ! -d "$kubeCfgPath" ]; then | |
echo "Directory '$kubeCfgPath' not exists" | |
exit | |
fi | |
export KUBECONFIG=$(for i in "$kubeCfgPath"/*; do echo $i; done | paste -sd':') | |
kubectl config view --flatten >$HOME/.kube/config | |
echo "Merged configs in directory '$kubeCfgPath' into $HOME/.kube/config" | |
# https://stuartleeks.com/posts/working-with-multiple-kubernetes-contexts/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment