Commit 7dd65d45 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 7ac76459
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -382,6 +382,7 @@ Here are variables supported to configure review environments:
| `K8S_REVIEW_URL`         | Kubernetes API url for `review` env  _(only define if using exploded kubeconfig parameters and if different from default)_    | `$K8S_URL` |
| `K8S_REVIEW_CA_CERT`     | the Kubernetes server certificate authority for `review` env _(only define if using exploded kubeconfig parameters and if different from default)_ | `$K8S_CA_CERT` |
| :lock: `K8S_REVIEW_TOKEN`| service account token for `review` env _(only define if using exploded kubeconfig parameters and if different from default)_ | `$K8S_TOKEN` |
| `K8S_REVIEW_AUTOSTOP_DURATION`| The amount of time before GitLab will automatically stop `review` environments | `4 hours` |

### Integration environment configuration

+5 −0
Original line number Diff line number Diff line
@@ -92,6 +92,11 @@
          "description": "The application name for review env (only define if different from global)",
          "advanced": true
        },
        {
          "name": "K8S_REVIEW_AUTOSTOP_DURATION",
          "description": "The amount of time before GitLab will automatically stop `review` environments",
          "default": "4 hours"
        },
        {
          "name": "K8S_REVIEW_ENVIRONMENT_URL",
          "type": "url",
+4 −0
Original line number Diff line number Diff line
@@ -63,7 +63,9 @@ variables:
  K8S_KUBE_SCORE_IMAGE: "registry.hub.docker.com/zegl/kube-score:latest"
  K8S_BASE_APP_NAME: "$CI_PROJECT_NAME"
  K8S_SCRIPTS_DIR: "."
  # deprecated, backward compatibility
  K8S_REVIEW_ENVIRONMENT_SCHEME: "https"
  K8S_REVIEW_AUTOSTOP_DURATION: "4 hours"

  # default: one-click deploy
  K8S_PROD_DEPLOY_STRATEGY: manual
@@ -751,10 +753,12 @@ k8s-review:
    ENV_CA_CERT: "$K8S_REVIEW_CA_CERT"
    ENV_KUBE_CONFIG: "$K8S_REVIEW_KUBE_CONFIG"
    ENV_URL: "${K8S_REVIEW_ENVIRONMENT_URL}"
    # deprecated, backward compatibility
    ENV_URL_LEGACY: "${K8S_REVIEW_ENVIRONMENT_SCHEME}://${CI_PROJECT_NAME}-${CI_ENVIRONMENT_SLUG}.${K8S_REVIEW_ENVIRONMENT_DOMAIN}"
  environment:
    name: review/$CI_COMMIT_REF_NAME
    on_stop: k8s-cleanup-review
    auto_stop_in: "$K8S_REVIEW_AUTOSTOP_DURATION"
  resource_group: review/$CI_COMMIT_REF_NAME
  rules:
    # exclude tags