Last active
February 25, 2022 07:35
-
-
Save FINCTIVE/99ee6d1bd6f97961c62a27acb968a331 to your computer and use it in GitHub Desktop.
Merge multiple kubeconfig files, fish shell script
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
# 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
reference: https://stackoverflow.com/questions/46184125/how-to-merge-kubectl-config-file-with-kube-config