Skip to content

Scale deployments directly from the environment page

Owners

UX: ? FE: probably (@dennistang) BE: @matteeyah

Description

Auto DevOps can leverage variables to define how many pods should be created during a deployment (PRODUCTION_REPLICAS, CANARY_PRODUCTION_REPLICAS, etc.): https://docs.gitlab.com/ee/topics/autodevops/#advanced-replica-variables-setup.

We should espose this variables in the CI/CD > Environments page, and allow users to easily change this values in the UI. After the change, we can automate the redeployment to apply the new number of requested pods.

### Original proposal

In the **CI/CD > Environments** view, for each deployment we can show 1. number of pods (e.g., `PRODUCTION_REPLICAS`) 1. if canaries are configured, number of canary pods (e.g., `CANARY_PRODUCTION_REPLICAS`) 1. if a deploy action is available in the related pipeline: 1. make it easy to change the values in the UI (since they are numbers, edit field with arrows to increase/decrease) 1. allow saving the new values, and automatically redeploy the application to apply the new values

This should support also environment-specific variables (related to https://gitlab.com/gitlab-org/gitlab-ce/issues/41436) in a transparent way for the user.

In the UI, we should make users aware that this flow works if they are using Auto DevOps, or if they implement a similar logic in their deployment jobs. It will link to documentation on how to leverage environment variables to deploy applications with a specific number of pods.

Proposal

A new Scale deployment link is added next to the Instances title for each environment:

scale-apps

When the link is clicked, the deploy board section is expanded inline to show the scaling options. The Scale deployment link is no longer available since we have entered scaling mode.

A message is shown at the top of the new section to inform users that this feature only works with certain configurations:

Please, make sure your deployment job is compatible with scaling. Read our documentation for more details.

TODO: Determine the documentation link

Below, the new option is shown. The description text informs the user that this change will affect deployments that happen after they save:

Increase or decrease the number of instances used for this environment. This will affect future deployments.

The actual value is edited through a text field with arrow controls for easy modification.

Finally, there is a Save and Cancel button.

If the user collapses the environment, this section should be collapsed along with the rest of the deploy board.

scale-apps--expanded

We will check whether the configuration is compatible with deployment scaling:

  1. Create environment_scaling that is gonna have all scaling options,

  2. We gonna update enviroment_scaling once show the page,

  3. We forbid updating environment_scaling if you have PRODUCTION_REPLICAS (for ex.) set as Secret Variable, as this is conflicting,

  4. We show the error message, linking to edit of Secret Variables, the user deletes them, save, gets back to this page, clicks save and it's done,

  5. We make environment_scaling to be included in variables sent to the runner.

If we detect that the configuration is incompatible, the default message is hidden and we show this message in a warning box:

Some of the secret variables in this project are incompatible with deployment scaling. Read our documentation for more details.

Secret variables will link to project/settings/ci_cd

TODO: Determine which docs page to link to for the second anchor

The field and Save button will be disabled.

The content of the field will be taken from the 'conflicting' variable.

scale-apps--incompatible

Edited by Dennis Tang