Skip to content

Merge KubeConfig Files

How do I merge a new kubeconfig file into my existing one? Try this:

Bash
# Backup
backup="~/.kube/config.$(date '+$Y$m$d')"
mv ~/.kube/config ${backup}

# Set $KUBECONFIG to the list if desired files
export KUBECONFIG=${backup}:~/someotherconfig

# Check if all is working as you expect
kubectl config view

# Write to disk
umask 077
kubectl config view --flatten > ~/.kube/config
unset KUBECONFIG