|
| 1 | +.auto-deploy: |
| 2 | + image: "ghcr.io/opencloudengineer/lambda:v0.2.0" |
| 3 | + dependencies: [] |
| 4 | +review: |
| 5 | + extends: .auto-deploy |
| 6 | + stage: review |
| 7 | + script: |
| 8 | + - auto-deploy check_kube_domain |
| 9 | + - auto-deploy download_chart |
| 10 | + - auto-deploy ensure_namespace |
| 11 | + - auto-deploy create_secret |
| 12 | + - auto-deploy deploy |
| 13 | + - auto-deploy persist_environment_url |
| 14 | + environment: |
| 15 | + name: review/$CI_COMMIT_REF_NAME |
| 16 | + url: http://$CI_PROJECT_ID-$CI_ENVIRONMENT_SLUG.$KUBE_INGRESS_BASE_DOMAIN |
| 17 | + on_stop: stop_review |
| 18 | + artifacts: |
| 19 | + paths: [environment_url.txt, tiller.log] |
| 20 | + when: always |
| 21 | + rules: |
| 22 | + - if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""' |
| 23 | + when: never |
| 24 | + - if: '$CI_COMMIT_BRANCH == "master"' |
| 25 | + when: never |
| 26 | + - if: '$REVIEW_DISABLED' |
| 27 | + when: never |
| 28 | + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' |
| 29 | +stop_review: |
| 30 | + extends: .auto-deploy |
| 31 | + stage: cleanup |
| 32 | + variables: |
| 33 | + GIT_STRATEGY: none |
| 34 | + script: |
| 35 | + - auto-deploy delete |
| 36 | + environment: |
| 37 | + name: review/$CI_COMMIT_REF_NAME |
| 38 | + action: stop |
| 39 | + allow_failure: true |
| 40 | + rules: |
| 41 | + - if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""' |
| 42 | + when: never |
| 43 | + - if: '$CI_COMMIT_BRANCH == "master"' |
| 44 | + when: never |
| 45 | + - if: '$REVIEW_DISABLED' |
| 46 | + when: never |
| 47 | + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' |
| 48 | + when: manual |
| 49 | +# Staging deploys are disabled by default since |
| 50 | +# continuous deployment to production is enabled by default |
| 51 | +# If you prefer to automatically deploy to staging and |
| 52 | +# only manually promote to production, enable this job by setting |
| 53 | +# STAGING_ENABLED. |
| 54 | +staging: |
| 55 | + extends: .auto-deploy |
| 56 | + stage: staging |
| 57 | + script: |
| 58 | + - auto-deploy check_kube_domain |
| 59 | + - auto-deploy download_chart |
| 60 | + - auto-deploy ensure_namespace |
| 61 | + - auto-deploy create_secret |
| 62 | + - auto-deploy deploy |
| 63 | + environment: |
| 64 | + name: staging |
| 65 | + url: http://$CI_PROJECT_PATH_SLUG-staging.$KUBE_INGRESS_BASE_DOMAIN |
| 66 | + rules: |
| 67 | + - if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""' |
| 68 | + when: never |
| 69 | + - if: '$CI_COMMIT_BRANCH != "master"' |
| 70 | + when: never |
| 71 | + - if: '$STAGING_ENABLED' |
| 72 | +# Canaries are disabled by default, but if you want them, |
| 73 | +# and know what the downsides are, you can enable this by setting |
| 74 | +# CANARY_ENABLED. |
| 75 | +canary: |
| 76 | + extends: .auto-deploy |
| 77 | + stage: canary |
| 78 | + allow_failure: true |
| 79 | + script: |
| 80 | + - auto-deploy check_kube_domain |
| 81 | + - auto-deploy download_chart |
| 82 | + - auto-deploy ensure_namespace |
| 83 | + - auto-deploy create_secret |
| 84 | + - auto-deploy deploy canary |
| 85 | + environment: |
| 86 | + name: production |
| 87 | + url: http://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN |
| 88 | + rules: |
| 89 | + - if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""' |
| 90 | + when: never |
| 91 | + - if: '$CI_COMMIT_BRANCH != "master"' |
| 92 | + when: never |
| 93 | + - if: '$CANARY_ENABLED' |
| 94 | + when: manual |
| 95 | +.production: &production_template |
| 96 | + extends: .auto-deploy |
| 97 | + stage: production |
| 98 | + script: |
| 99 | + - auto-deploy check_kube_domain |
| 100 | + - auto-deploy download_chart |
| 101 | + - auto-deploy ensure_namespace |
| 102 | + - auto-deploy create_secret |
| 103 | + - auto-deploy deploy |
| 104 | + - auto-deploy delete canary |
| 105 | + - auto-deploy delete rollout |
| 106 | + - auto-deploy persist_environment_url |
| 107 | + environment: |
| 108 | + name: production |
| 109 | + url: http://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN |
| 110 | + artifacts: |
| 111 | + paths: [environment_url.txt, tiller.log] |
| 112 | + when: always |
| 113 | +production: |
| 114 | + !!merge <<: *production_template |
| 115 | + rules: |
| 116 | + - if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""' |
| 117 | + when: never |
| 118 | + - if: '$STAGING_ENABLED' |
| 119 | + when: never |
| 120 | + - if: '$CANARY_ENABLED' |
| 121 | + when: never |
| 122 | + - if: '$INCREMENTAL_ROLLOUT_ENABLED' |
| 123 | + when: never |
| 124 | + - if: '$INCREMENTAL_ROLLOUT_MODE' |
| 125 | + when: never |
| 126 | + - if: '$CI_COMMIT_BRANCH == "master"' |
| 127 | +production_manual: |
| 128 | + !!merge <<: *production_template |
| 129 | + allow_failure: false |
| 130 | + rules: |
| 131 | + - if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""' |
| 132 | + when: never |
| 133 | + - if: '$INCREMENTAL_ROLLOUT_ENABLED' |
| 134 | + when: never |
| 135 | + - if: '$INCREMENTAL_ROLLOUT_MODE' |
| 136 | + when: never |
| 137 | + - if: '$CI_COMMIT_BRANCH == "master" && $STAGING_ENABLED' |
| 138 | + when: manual |
| 139 | + - if: '$CI_COMMIT_BRANCH == "master" && $CANARY_ENABLED' |
| 140 | + when: manual |
| 141 | +# This job implements incremental rollout on for every push to `master`. |
| 142 | +.rollout: &rollout_template |
| 143 | + extends: .auto-deploy |
| 144 | + script: |
| 145 | + - auto-deploy check_kube_domain |
| 146 | + - auto-deploy download_chart |
| 147 | + - auto-deploy ensure_namespace |
| 148 | + - auto-deploy create_secret |
| 149 | + - auto-deploy deploy rollout $ROLLOUT_PERCENTAGE |
| 150 | + - auto-deploy scale stable $((100-ROLLOUT_PERCENTAGE)) |
| 151 | + - auto-deploy delete canary |
| 152 | + - auto-deploy persist_environment_url |
| 153 | + environment: |
| 154 | + name: production |
| 155 | + url: http://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN |
| 156 | + artifacts: |
| 157 | + paths: [environment_url.txt, tiller.log] |
| 158 | + when: always |
| 159 | +.manual_rollout_template: &manual_rollout_template |
| 160 | + !!merge <<: *rollout_template |
| 161 | + stage: production |
| 162 | + resource_group: production |
| 163 | + allow_failure: true |
| 164 | + rules: |
| 165 | + - if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""' |
| 166 | + when: never |
| 167 | + - if: '$INCREMENTAL_ROLLOUT_MODE == "timed"' |
| 168 | + when: never |
| 169 | + - if: '$CI_COMMIT_BRANCH != "master"' |
| 170 | + when: never |
| 171 | + # $INCREMENTAL_ROLLOUT_ENABLED is for compatibility with pre-GitLab 11.4 syntax |
| 172 | + - if: '$INCREMENTAL_ROLLOUT_MODE == "manual" || $INCREMENTAL_ROLLOUT_ENABLED' |
| 173 | + when: manual |
| 174 | +.timed_rollout_template: &timed_rollout_template |
| 175 | + !!merge <<: *rollout_template |
| 176 | + rules: |
| 177 | + - if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""' |
| 178 | + when: never |
| 179 | + - if: '$INCREMENTAL_ROLLOUT_MODE == "manual"' |
| 180 | + when: never |
| 181 | + - if: '$CI_COMMIT_BRANCH != "master"' |
| 182 | + when: never |
| 183 | + - if: '$INCREMENTAL_ROLLOUT_MODE == "timed"' |
| 184 | + when: delayed |
| 185 | + start_in: 5 minutes |
| 186 | +timed rollout 10%: |
| 187 | + !!merge <<: *timed_rollout_template |
| 188 | + stage: incremental rollout 10% |
| 189 | + variables: |
| 190 | + ROLLOUT_PERCENTAGE: 10 |
| 191 | +timed rollout 25%: |
| 192 | + !!merge <<: *timed_rollout_template |
| 193 | + stage: incremental rollout 25% |
| 194 | + variables: |
| 195 | + ROLLOUT_PERCENTAGE: 25 |
| 196 | +timed rollout 50%: |
| 197 | + !!merge <<: *timed_rollout_template |
| 198 | + stage: incremental rollout 50% |
| 199 | + variables: |
| 200 | + ROLLOUT_PERCENTAGE: 50 |
| 201 | +timed rollout 100%: |
| 202 | + !!merge <<: *timed_rollout_template |
| 203 | + !!merge <<: *production_template |
| 204 | + stage: incremental rollout 100% |
| 205 | + variables: |
| 206 | + ROLLOUT_PERCENTAGE: 100 |
| 207 | +rollout 10%: |
| 208 | + !!merge <<: *manual_rollout_template |
| 209 | + variables: |
| 210 | + ROLLOUT_PERCENTAGE: 10 |
| 211 | +rollout 25%: |
| 212 | + !!merge <<: *manual_rollout_template |
| 213 | + variables: |
| 214 | + ROLLOUT_PERCENTAGE: 25 |
| 215 | +rollout 50%: |
| 216 | + !!merge <<: *manual_rollout_template |
| 217 | + variables: |
| 218 | + ROLLOUT_PERCENTAGE: 50 |
| 219 | +rollout 100%: |
| 220 | + !!merge <<: *manual_rollout_template |
| 221 | + !!merge <<: *production_template |
| 222 | + allow_failure: false |
0 commit comments