Created
September 2, 2025 10:06
-
-
Save dgacias/e31b866d629f3058a79792ae3134cb29 to your computer and use it in GitHub Desktop.
Merge kubeconfig function for bash
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
| #Add this function to your .bashrc file. | |
| kube-merge() { | |
| local files=(~/.kube/config ~/.kube/*.yml) | |
| KUBECONFIG=$(IFS=:; echo "${files[*]}") kubectl config view --merge --flatten > ~/.kube/config | |
| unset KUBECONFIG | |
| echo "Kubeconfigs merged in ~/.kube/config" | |
| echo "KUBECONFIG var has been unset" | |
| echo "You can list your current contexts with: $ kubectl config get-contexts" | |
| } | |
| #Relog your session or execute this command: $ source ~/.bashrc | |
| #Then you can execute $ kube-merge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment