Skip to content

Merging Multiple Kubeconfig Files

Merge

  • old (~/.kube/config)

  • new - some new_config

  • add one more test_config

Bash
KUBECONFIG=~/.kube/config:config_new kubectl config view --merge --flatten > config.new
  • More then one config
Bash
KUBECONFIG=~/.kube/config:config_1:config_2 kubectl config view --merge --flatten > config.new

Backup - just in case :)

Bash
mv $HOME/.kube/config $HOME/.kube/config.old
Bash
cat config.new > ~/.kube/config

Export config | current context

Bash
kubectl config view --minify --flatten
Bash
kubectl config view --minify --flatten --context prod-pve