Skip to content

Manage multiple clusters

Victor Cuadrado Juan edited this page Mar 11, 2020 · 10 revisions

You can switch the context when you run the make targets by specifying CLUSTER_NAME as environment variable.

If the kind backend is used (which is by default), it will create a new docker container and will create a cluster matching the CLUSTER_NAME passed.

Note In case you don't specify any CLUSTER_NAME, it will set it to the name of the BACKEND you are using, whic is kind by default. Remember to carry on the CLUSTER_NAME environment variable in all the make targets you run, as each one will be executed in the context of the specified cluster.

After a new cluster is created (e.g. by running CLUSTER_NAME=test make kind) a new folder will be created with the name of the cluster with build prefixed (e.g. buildtest) containing an .envrc file which can be sourced and a kubeconfig file to connect to the cluster.

If you want to easily change between different clusters' build folders, install direnv, and the .envrc will get loaded automatically when you enter the build dir, and unloaded when you exit.

Examples

Always in the catapult folder:

$> pushd catapult

Create a new kind cluster named test1:

$> [..] CLUSTER_NAME=test1 make k8s

Destroy test2:

$> [..] CLUSTER_NAME=test2 make clean

Deploy a new kind cluster test3 and run smoke test on it:

$> [..] CLUSTER_NAME=test3 make all smoke

For other backends:

Create a new gke cluster named testgke:

$> [..] CLUSTER_NAME=testgke BACKEND=gke make all
Clone this wiki locally