Multiple Kubernetes clusters for Auto DevOps

When using Auto DevOps, you can deploy different environments to different Kubernetes clusters, due to the 1:1 connection existing between them.

The Deploy Job template used by Auto DevOps defines 3 environment names:

  • review/ (every environment starting with review/)
  • staging
  • production

Those environments are tied to jobs using Auto Deploy, so except for the environment scope, they must have a different deployment domain. You must define a separate KUBE_INGRESS_BASE_DOMAIN variable for each of the above based on the environment.

The following table is an example of how to configure the three different clusters:

Cluster name Cluster environment scope KUBE_INGRESS_BASE_DOMAIN variable value Variable environment scope Notes
review review/* review.example.com review/* The review cluster which runs all Review Apps. * is a wildcard, used by every environment name starting with review/.
staging staging staging.example.com staging (Optional) The staging cluster which runs the deployments of the staging environments. You must enable it first.
production production example.com production The production cluster which runs the production environment deployments. You can use incremental rollouts.

To add a different cluster for each environment:

  1. Navigate to your project’s Infrastructure > Kubernetes clusters.
  2. Create the Kubernetes clusters with their respective environment scope, as described from the table above.
  3. After creating the clusters, navigate to each cluster and install Ingress. Wait for the Ingress IP address to be assigned.
  4. Make sure you’ve configured your DNS with the specified Auto DevOps domains.
  5. Navigate to each cluster’s page, through Infrastructure > Kubernetes clusters, and add the domain based on its Ingress IP address.

After completing configuration, test your setup by creating a merge request. Verify whether your application deployed as a Review App in the Kubernetes cluster with the review/* environment scope. Similarly, check the other environments.

Cluster environment scope isn’t respected when checking for active Kubernetes clusters. For multi-cluster setup to work with Auto DevOps, create a fallback cluster with Cluster environment scope set to *. A new cluster isn’t required. You can use any of the clusters already added.