|
| 1 | +pr: none |
| 2 | +trigger: |
| 3 | + branches: |
| 4 | + include: |
| 5 | + - master |
| 6 | + paths: |
| 7 | + exclude: |
| 8 | + - docs/ |
| 9 | + - environment_setup/ |
| 10 | + - ml_service/util/create_scoring_image.* |
| 11 | + - ml_service/util/smoke_test_scoring_service.py |
| 12 | + |
| 13 | +variables: |
| 14 | +- group: 'devopsforai-aml-vg' |
| 15 | +- name: 'helmVersion' |
| 16 | + value: 'v3.0.1' |
| 17 | +- name: 'helmDownloadURL' |
| 18 | + value: 'https://get.helm.sh/helm-$HELM_VERSION-linux-amd64.tar.gz' |
| 19 | +- name: 'blueReleaseName' |
| 20 | + value: 'model-blue' |
| 21 | +- name: 'greenReleaseName' |
| 22 | + value: 'model-green' |
| 23 | +- name: 'SCORE_SCRIPT' |
| 24 | + value: 'scoreA.py' |
| 25 | + |
| 26 | + |
| 27 | +stages: |
| 28 | +- stage: 'Building' |
| 29 | + jobs: |
| 30 | + - job: "Build_Scoring_image" |
| 31 | + timeoutInMinutes: 0 |
| 32 | + pool: |
| 33 | + vmImage: 'ubuntu-latest' |
| 34 | + container: mcr.microsoft.com/mlops/python:latest |
| 35 | + steps: |
| 36 | + - task: AzureCLI@1 |
| 37 | + inputs: |
| 38 | + azureSubscription: '$(WORKSPACE_SVC_CONNECTION)' |
| 39 | + scriptLocation: inlineScript |
| 40 | + inlineScript: | |
| 41 | + set -e |
| 42 | + export SUBSCRIPTION_ID=$(az account show --query id -o tsv) |
| 43 | + python ml_service/util/create_scoring_image.py --output_image_location_file image_location.txt |
| 44 | + displayName: 'Create Scoring Image' |
| 45 | + name: 'buildscoringimage' |
| 46 | + |
| 47 | + - publish: image_location.txt |
| 48 | + artifact: image_location |
| 49 | + |
| 50 | + - publish: $(System.DefaultWorkingDirectory)/charts |
| 51 | + artifact: allcharts |
| 52 | + |
| 53 | + |
| 54 | +- stage: 'Blue_Staging' |
| 55 | + jobs: |
| 56 | + - deployment: "Deploy_to_Staging" |
| 57 | + timeoutInMinutes: 0 |
| 58 | + environment: abtestenv |
| 59 | + strategy: |
| 60 | + runOnce: |
| 61 | + deploy: |
| 62 | + steps: |
| 63 | + - script: | |
| 64 | + IMAGE_LOCATION="$(cat $(Pipeline.Workspace)/image_location/image_location.txt)" |
| 65 | + echo "##vso[task.setvariable variable=IMAGE_LOCATION]$IMAGE_LOCATION" |
| 66 | + displayName: 'Get Image Location' |
| 67 | + - template: azdo-helm-upgrade.yml |
| 68 | + parameters: |
| 69 | + chartPath: '$(Pipeline.Workspace)/allcharts/abtest-model' |
| 70 | + releaseName: $(blueReleaseName) |
| 71 | + overrideValues: 'deployment.name=$(blueReleaseName),deployment.bluegreen=blue,deployment.image.name=$(IMAGE_LOCATION)' |
| 72 | + |
| 73 | +- stage: 'Blue_50' |
| 74 | + jobs: |
| 75 | + - job: 'Blue_Rollout_50' |
| 76 | + displayName: 50 50 rollout to blue environment |
| 77 | + timeoutInMinutes: 0 |
| 78 | + steps: |
| 79 | + - template: azdo-helm-upgrade.yml |
| 80 | + parameters: |
| 81 | + chartPath: '$(System.DefaultWorkingDirectory)/charts/abtest-istio' |
| 82 | + releaseName: 'abtest-istio' |
| 83 | + overrideValues: 'weight.blue=50,weight.green=50' |
| 84 | + |
| 85 | +- stage: 'Blue_100' |
| 86 | + jobs: |
| 87 | + - deployment: 'blue_Rollout_100' |
| 88 | + timeoutInMinutes: 0 |
| 89 | + environment: abtestenv |
| 90 | + strategy: |
| 91 | + runOnce: |
| 92 | + deploy: |
| 93 | + steps: |
| 94 | + - template: azdo-helm-upgrade.yml |
| 95 | + parameters: |
| 96 | + chartPath: '$(Pipeline.Workspace)/allcharts/abtest-istio' |
| 97 | + releaseName: 'abtest-istio' |
| 98 | + overrideValues: 'weight.blue=100,weight.green=0' |
| 99 | + |
| 100 | +- stage: 'Rollback' |
| 101 | + dependsOn: 'Blue_100' |
| 102 | + condition: failed() |
| 103 | + jobs: |
| 104 | + - deployment: 'Roll_Back' |
| 105 | + displayName: 'Roll Back after failure' |
| 106 | + environment: abtestenv |
| 107 | + strategy: |
| 108 | + runOnce: |
| 109 | + deploy: |
| 110 | + steps: |
| 111 | + - template: azdo-helm-upgrade.yml |
| 112 | + parameters: |
| 113 | + chartPath: '$(Pipeline.Workspace)/allcharts/abtest-istio' |
| 114 | + releaseName: 'abtest-istio' |
| 115 | + overrideValues: 'weight.blue=0,weight.green=100' |
| 116 | + |
| 117 | +- stage: 'Set_Production_Tag' |
| 118 | + dependsOn: 'Blue_100' |
| 119 | + condition: succeeded() |
| 120 | + jobs: |
| 121 | + - deployment: 'green_blue_tagging' |
| 122 | + timeoutInMinutes: 0 |
| 123 | + environment: abtestenv |
| 124 | + strategy: |
| 125 | + runOnce: |
| 126 | + deploy: |
| 127 | + steps: |
| 128 | + - script: | |
| 129 | + IMAGE_LOCATION="$(cat $(Pipeline.Workspace)/image_location/image_location.txt)" |
| 130 | + echo "##vso[task.setvariable variable=IMAGE_LOCATION]$IMAGE_LOCATION" |
| 131 | + displayName: 'Get Image Location' |
| 132 | + - template: azdo-helm-upgrade.yml |
| 133 | + parameters: |
| 134 | + chartPath: '$(Pipeline.Workspace)/allcharts/abtest-model' |
| 135 | + releaseName: $(greenReleaseName) |
| 136 | + overrideValues: 'deployment.name=$(greenReleaseName),deployment.bluegreen=green,deployment.image.name=$(IMAGE_LOCATION)' |
| 137 | + |
| 138 | +- stage: 'Green_100' |
| 139 | + jobs: |
| 140 | + - job: 'Prod_Rollout_100' |
| 141 | + timeoutInMinutes: 0 |
| 142 | + steps: |
| 143 | + - template: azdo-helm-upgrade.yml |
| 144 | + parameters: |
| 145 | + chartPath: '$(System.DefaultWorkingDirectory)/charts/abtest-istio' |
| 146 | + releaseName: 'abtest-istio' |
| 147 | + overrideValues: 'weight.blue=0,weight.green=100' |
| 148 | + |
| 149 | +- stage: 'Disable_blue' |
| 150 | + condition: always() |
| 151 | + jobs: |
| 152 | + - job: 'blue_disable' |
| 153 | + timeoutInMinutes: 0 |
| 154 | + steps: |
| 155 | + - template: azdo-helm-install.yml |
| 156 | + - task: HelmDeploy@0 |
| 157 | + displayName: 'helm uninstall blue' |
| 158 | + inputs: |
| 159 | + connectionType: 'Kubernetes Service Connection' |
| 160 | + kubernetesServiceConnection: $(K8S_AB_SERVICE_CONNECTION) |
| 161 | + command: delete |
| 162 | + arguments: $(blueReleaseName) --namespace $(K8S_AB_NAMESPACE) |
0 commit comments