Skip to content

Instantly share code, notes, and snippets.

@kumakichi
Created May 28, 2021 01:44
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 kumakichi/32bc9f47ccfd69bc3094253a8303ffb0 to your computer and use it in GitHub Desktop.
Save kumakichi/32bc9f47ccfd69bc3094253a8303ffb0 to your computer and use it in GitHub Desktop.
merge multiple kubernetes configs
#!/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