DEV Community

Gloria Adhiambo
Gloria Adhiambo

Posted on

Merge Multiple kubeconfig Files into One

  1. Make a copy of your kubeconfig file

cp ~/.kube/config ~/.kube/config-backup

export KUBECONFIG=~/.kube/config:$(find . -type f | tr '\n' ':')

2 . Merge all kubeconfig files into one

kubectl config view --flatten > all-in-one-kubeconfig.yaml

3 . Replace the old config file with the new merged one

mv all-in-one-kubeconfig.yaml ~/.kube/config

4 .Verify it works

Display all your clusters defined in the kubeconfig:

kubectl config get-clusters

Top comments (0)