Commit bec897e5 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat!: support environment auto-stop

BREAKING CHANGE: now review environments will auto stop after 4 hours
by default. Configurable (see doc).
parent 75ecbf51
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -265,6 +265,7 @@ Here are variables supported to configure review environments:
| `HELM_REVIEW_NAMESPACE`  | The Kubernetes namespace to use for `review` env _(only define to override default)_ | `$KUBE_NAMESPACE` |
| :lock: `HELM_REVIEW_KUBE_CONFIG` | Specific kubeconfig for `review` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` |
| `HELM_REVIEW_VALUES`     | The [Values file](https://helm.sh/docs/chart_template_guide/values_files/) to use with `review` environments | _none_ |
| `HELM_REVIEW_AUTOSTOP_DURATION`| The amount of time before GitLab will automatically stop `review` environments | `4 hours` |

### Integration environment configuration

@@ -282,6 +283,7 @@ Here are variables supported to configure the integration environment:
| `HELM_INTEG_NAMESPACE`   | The Kubernetes namespace to use for `integration` env _(only define to override default)_ | `$KUBE_NAMESPACE` |
| :lock: `HELM_INTEG_KUBE_CONFIG` | Specific kubeconfig for `integration` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` |
| `HELM_INTEG_VALUES`      | The [Values file](https://helm.sh/docs/chart_template_guide/values_files/) to use with the `integration` environment | _none_ |
| `HELM_INTEG_AUTOSTOP_DURATION`| The amount of time before GitLab will automatically stop the `integration` env | `never` |

### Staging environment configuration

@@ -299,6 +301,7 @@ Here are variables supported to configure the staging environment:
| `HELM_STAGING_NAMESPACE` | The Kubernetes namespace to use for `staging` env _(only define to override default)_ | `$KUBE_NAMESPACE` |
| :lock: `HELM_STAGING_KUBE_CONFIG` | Specific kubeconfig for `staging` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` |
| `HELM_STAGING_VALUES`    | The [Values file](https://helm.sh/docs/chart_template_guide/values_files/) to use with the staging environment | _none_ |
| `HELM_STAGING_AUTOSTOP_DURATION`| The amount of time before GitLab will automatically stop the `staging` env | `never` |

### Production environment configuration

+15 −0
Original line number Diff line number Diff line
@@ -249,6 +249,11 @@
          "default": "${HELM_BASE_APP_NAME}-${CI_ENVIRONMENT_SLUG}",
          "advanced": true
        },
        {
          "name": "HELM_REVIEW_AUTOSTOP_DURATION",
          "description": "The amount of time before GitLab will automatically stop `review` environments",
          "default": "4 hours"
        },
        {
          "name": "HELM_REVIEW_ENVIRONMENT_URL",
          "type": "url",
@@ -286,6 +291,11 @@
          "default": "${HELM_BASE_APP_NAME}-integration",
          "advanced": true
        },
        {
          "name": "HELM_INTEG_AUTOSTOP_DURATION",
          "description": "The amount of time before GitLab will automatically stop the `integration` env",
          "default": "never"
        },
        {
          "name": "HELM_INTEG_ENVIRONMENT_URL",
          "type": "url",
@@ -323,6 +333,11 @@
          "default": "${HELM_BASE_APP_NAME}-staging",
          "advanced": true
        },
        {
          "name": "HELM_STAGING_AUTOSTOP_DURATION",
          "description": "The amount of time before GitLab will automatically stop the `staging` env",
          "default": "never"
        },
        {
          "name": "HELM_STAGING_ENVIRONMENT_URL",
          "type": "url",
+8 −0
Original line number Diff line number Diff line
@@ -121,7 +121,11 @@ variables:
  # [optional]  HELM_PROD_APP_NAME    : specific Helm application name in production env (defaults to $HELM_BASE_APP_NAME)

  HELM_BASE_APP_NAME: "$CI_PROJECT_NAME"
  # deprecated, backward compatibility
  HELM_REVIEW_ENVIRONMENT_SCHEME: "https"
  HELM_REVIEW_AUTOSTOP_DURATION: "4 hours"
  HELM_INTEG_AUTOSTOP_DURATION: "never"
  HELM_STAGING_AUTOSTOP_DURATION: "never"
  HELM_PUBLISH_ON: "prod"

  # default: one-click deploy
@@ -1024,6 +1028,7 @@ helm-review:
    ENV_TYPE: review
    ENV_APP_NAME: "$HELM_REVIEW_APP_NAME"
    ENV_URL: "${HELM_REVIEW_ENVIRONMENT_URL}"
    # deprecated, backward compatibility
    ENV_URL_LEGACY: "${HELM_REVIEW_ENVIRONMENT_SCHEME}://${CI_PROJECT_NAME}-${CI_ENVIRONMENT_SLUG}.${HELM_REVIEW_ENVIRONMENT_DOMAIN}"
    ENV_KUBE_CONFIG: "$HELM_REVIEW_KUBE_CONFIG"
    ENV_NAMESPACE: "$HELM_REVIEW_NAMESPACE"
@@ -1031,6 +1036,7 @@ helm-review:
  environment:
    name: review/$CI_COMMIT_REF_NAME
    on_stop: helm-cleanup-review
    auto_stop_in: "$HELM_REVIEW_AUTOSTOP_DURATION"
  resource_group: review/$CI_COMMIT_REF_NAME
  rules:
    # exclude tags and on $HELM_REVIEW_ENABLED not set
@@ -1098,6 +1104,7 @@ helm-integration:
  environment:
    name: integration
    on_stop: helm-cleanup-integration
    auto_stop_in: "$HELM_INTEG_AUTOSTOP_DURATION"
  resource_group: integration
  rules:
    # exclude on $HELM_INTEG_ENABLED not set
@@ -1164,6 +1171,7 @@ helm-staging:
  environment:
    name: staging
    on_stop: helm-cleanup-staging
    auto_stop_in: "$HELM_STAGING_AUTOSTOP_DURATION"
  resource_group: staging
  rules:
    # exclude on $HELM_STAGING_ENABLED not set