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=https://1.2.3.4 --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

 

 

https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/

and

https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/

 

Leave a Reply

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