Kubernetes: configure access to multiple clusters

The idea behind this is to enable you to swap control of different clusters using:

kubectl config use-context

With a config file (e.g. config-demo), you can update it using kubectl config --kube-config=config-demo. E.g.

kubectl config --kubeconfig=config-demo set-cluster development --server= --certificate-authority=fake-ca-file

and view the updates using cat config-demo or

kubectl config --kubeconfig=config-demo view

and to just see the current context use:

kubectl config --kubeconfig=config-demo view --minify

Note: each context is a triple – i.e.

  • cluster
  • user
  • namespace


The KUBECONFIG environment variable is a list of paths to configuration files.

To add configs:

export  KUBECONFIG=$KUBECONFIG:config-demo:config-demo-2







Leave a Reply

Your email address will not be published. Required fields are marked *