Commit 5436516a authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'feat/deployment-strategy' into 'master'

feat(deploy): redesign deployment strategy

See merge request to-be-continuous/helm!67
parents e71325c2 7f6e72ae
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ Here are variables supported to configure the production environment:
| `HELM_PROD_ENVIRONMENT_URL`| The production environment url _(only define for static environment URLs declaration and if different from default)_ | `$HELM_ENVIRONMENT_URL` |
| `HELM_PROD_NAMESPACE`    | The Kubernetes namespace to use for `production` env _(only define to override default)_ | `$KUBE_NAMESPACE` |
| :lock: `HELM_PROD_KUBE_CONFIG` | Specific kubeconfig for `production` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` |
| `AUTODEPLOY_TO_PROD`     | Set this variable to auto-deploy to production. If not set deployment to production will be `manual` (default behaviour). | _none_ (disabled) |
| `HELM_PROD_DEPLOY_STRATEGY`| Defines the deployment to production strategy. One of `manual` (i.e. _one-click_) or `auto`. | `manual` |
| `HELM_PROD_VALUES`       | The [Values file](https://helm.sh/docs/chart_template_guide/values_files/) to use with the production environment | _none_ |

### `helm-lint` job
@@ -407,6 +407,7 @@ This job publishes the packaged chart to a [chart repository](https://helm.sh/do
| :lock: `HELM_PUBLISH_PASSWORD`      | Helm registry password                       | `$CI_REGISTRY_PASSWORD` |
| `HELM_PUBLISH_URL`                  | The URL of the Helm repository to publish your Helm package.<br/>Supports both [chart repository](https://helm.sh/docs/topics/chart_repository/) or [OCI-based registry](https://helm.sh/docs/topics/registries/) (url must be prefixed with `oci://`) | `oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts` ([GitLab's container registry](https://docs.gitlab.com/ee/user/packages/container_registry/)) |
| `HELM_PUBLISH_ON`                   | Defines on which branch(es) the publish job shall be enabled (`prod` to enable on production branch only, `protected` to enable on protected references and `all` to enable on all Git references) | `prod`                  |
| `HELM_PUBLISH_STRATEGY`             | Defines the publish strategy. One of `manual` (i.e. _one-click_), `auto` or `none` (disabled). | `manual` |
| `HELM_CM_PUSH_PLUGIN_VERSION`       | cm-push plugin version to install (only when using `push` method with a regular chart [repository](https://helm.sh/docs/topics/chart_repository/)) | _none_ (latest) |


+12 −3
Original line number Diff line number Diff line
@@ -217,6 +217,13 @@
          "default": "prod",
          "type": "enum",
          "values": ["prod", "protected", "all"]
        },
        {
          "name": "HELM_PUBLISH_STRATEGY",
          "description": "Defines the publish strategy.",
          "type": "enum",
          "values": ["none", "manual", "auto"],
          "default": "manual"
        },
            {
          "name": "HELM_CM_PUSH_PLUGIN_VERSION",
@@ -343,9 +350,11 @@
      "enable_with": "HELM_PROD_ENABLED",
      "variables": [
        {
          "name": "AUTODEPLOY_TO_PROD",
          "type": "boolean",
          "description": "Set this variable to auto-deploy to production. If not set deployment to production will be manual (default behaviour)."
          "name": "HELM_PROD_DEPLOY_STRATEGY",
          "description": "Defines the deployment to production strategy.",
          "type": "enum",
          "values": ["manual", "auto"],
          "default": "manual"
        },
        {
          "name": "HELM_PROD_APP_NAME",
+11 −11
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ variables:
  # HELM_PUBLISH_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/release"
  # HELM_PUBLISH_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/release"
  HELM_PUBLISH_METHOD: "auto"
  HELM_PUBLISH_STRATEGY: "manual"
  
  HELM_REPOS: "stable@https://charts.helm.sh/stable bitnami@https://charts.bitnami.com/bitnami"

@@ -109,6 +110,9 @@ variables:
  HELM_REVIEW_ENVIRONMENT_SCHEME: "https"
  HELM_PUBLISH_ON: "prod"

  # default: one-click deploy
  HELM_PROD_DEPLOY_STRATEGY: manual

  # default production ref name (pattern)
  PROD_REF: '/^(master|main)$/'
  # default integration ref name (pattern)
@@ -900,13 +904,13 @@ helm-publish:
      when: never
    - if: '$HELM_PUBLISH_ON == "protected" && $CI_COMMIT_REF_PROTECTED != "true"'
      when: never
    - if: '$AUTODEPLOY_TO_PROD == "true"'
    - if: '$HELM_PUBLISH_STRATEGY == "manual"'
      exists:
        - "**/Chart.yaml"
    # else: manual + blocking
    - exists:
        - "**/Chart.yaml"
      when: manual
    - if: '$HELM_PUBLISH_STRATEGY == "auto"'
      exists:
        - "**/Chart.yaml"

# Deploy job prototype
# Can be extended to define a concrete environment
@@ -1208,10 +1212,6 @@ helm-production:
    # exclude if $HELM_PROD_ENABLED not set
    - if: '$HELM_PROD_ENABLED != "true"'
      when: never
    # if $AUTODEPLOY_TO_PROD: auto
    - if: '$AUTODEPLOY_TO_PROD == "true"'
    # else if PUBLISH_ON_PROD enabled: auto (because the publish job was blocking)
    - if: '$PUBLISH_ON_PROD == "true"'
    # else: manual, blocking
    - if: $CI_COMMIT_REF_NAME # useless test, just to prevent GitLab warning
    - if: '$HELM_PROD_DEPLOY_STRATEGY == "manual"'
      when: manual
    - if: '$HELM_PROD_DEPLOY_STRATEGY == "auto"'