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