How to merge kubectl config file with ~/.kube/config?

ghz 1years ago ⋅ 7104 views

Question

Is there a simple kubectl command to take a kubeconfig file (that contains a cluster+context+user) and merge it into the ~/.kube/config file as an additional context?


Answer

Do this:

export KUBECONFIG=~/.kube/config:~/someotherconfig 
kubectl config view --flatten

You can then pipe that out to a new file if needed.