Skip to content

Instantly share code, notes, and snippets.

@FINCTIVE
Last active February 25, 2022 07:35
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 FINCTIVE/99ee6d1bd6f97961c62a27acb968a331 to your computer and use it in GitHub Desktop.
Save FINCTIVE/99ee6d1bd6f97961c62a27acb968a331 to your computer and use it in GitHub Desktop.
Merge multiple kubeconfig files, fish shell script
# in order to use kubectx! (https://github.com/ahmetb/kubectx)
# Merge all kubeconfig files inside working directory
function merge_kubeconfig_files
# concatenate file names with ':'
# file1.conf:file2.conf:file3.conf
set -x KUBECONFIG (string join ':' *.conf)
kubectl config view --merge --flatten > merged_kubeconfig
set -e KUBECONFIG
mv merged_kubeconfig ~/.kube/config
chmod o-r ~/.kube/config
chmod g-r ~/.kube/config
echo "merged all *.conf files into ~/.kube/config"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment