forked from Azure/azureml-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-safe-rollout-k8s-online-endpoints.sh
72 lines (55 loc) · 2.44 KB
/
deploy-safe-rollout-k8s-online-endpoints.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
set -e
# <set_endpoint_name>
export ENDPOINT_NAME="<YOUR_ENDPOINT_NAME>"
# </set_endpoint_name>
# endpoint name
export ENDPOINT_NAME=endpt-k8s-`echo $RANDOM`
# <create_endpoint>
az ml online-endpoint create --name $ENDPOINT_NAME -f endpoints/online/amlarc/endpoint.yml
# </create_endpoint>
# <create_blue>
az ml online-deployment create --name blue --endpoint $ENDPOINT_NAME -f endpoints/online/amlarc/blue-deployment.yml --all-traffic
# </create_blue>
# <test_blue>
# comment this out as it's blocked by AKS policy for NONProd subscription.
# az ml online-endpoint invoke --name $ENDPOINT_NAME --request-file endpoints/online/model-1/sample-request.json
# </test_blue>
# <scale_blue>
az ml online-deployment update --name blue --endpoint $ENDPOINT_NAME --set instance_count=2
# </scale_blue>
# <create_green>
az ml online-deployment create --name green --endpoint $ENDPOINT_NAME -f endpoints/online/amlarc/green-deployment.yml
# </create_green>
# <get_traffic>
az ml online-endpoint show -n $ENDPOINT_NAME --query traffic
# </get_traffic>
# <test_green>
# comment this out as it's blocked by AKS policy for NONProd subscription.
# az ml online-endpoint invoke --name $ENDPOINT_NAME --deployment green --request-file endpoints/online/model-2/sample-request.json
# </test_green>
# supress printing secret
set +x
# <test_green_using_curl_get_key>
#get the key
ENDPOINT_KEY=$(az ml online-endpoint get-credentials -n $ENDPOINT_NAME -o tsv --query primaryKey)
# </test_green_using_curl_get_key>
set -x
# <test_green_using_curl>
# get the scoring uri
SCORING_URI=$(az ml online-endpoint show -n $ENDPOINT_NAME -o tsv --query scoring_uri)
# use curl to invoke the endpoint
# comment this out as it's blocked by AKS policy for NONProd subscription.
# curl --request POST "$SCORING_URI" --header "Authorization: Bearer $ENDPOINT_KEY" --header 'Content-Type: application/json' --header "azureml-model-deployment: green" --data @endpoints/online/model-2/sample-request.json
# </test_green_using_curl>
# <green_10pct_traffic>
az ml online-endpoint update --name $ENDPOINT_NAME --traffic "blue=90 green=10"
# </green_10pct_traffic>
# <green_100pct_traffic>
az ml online-endpoint update --name $ENDPOINT_NAME --traffic "blue=0 green=100"
# </green_100pct_traffic>
# <delete_blue>
az ml online-deployment delete --name blue --endpoint $ENDPOINT_NAME --yes --no-wait
# </delete_blue>
# <delete_endpoint>
az ml online-endpoint delete --name $ENDPOINT_NAME --yes --no-wait
# </delete_endpoint>