-
Notifications
You must be signed in to change notification settings - Fork 43
146 lines (125 loc) · 5.11 KB
/
deploy-aks-demo.yml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: "Deploy to AKS Demo"
on:
workflow_dispatch:
inputs:
imageTag:
default: latest
description: Image tag to be deployed
env:
ACR_NAME: bcdemo
AKS_NAME: benc
RES_GRP: aks
IMAGE_TAG: latest
DOMAIN: kube.benco.io
CERT: kube-benco-io-cert
RELEASE_NAME: demosmilr
jobs:
# ==================================================================================
# Continuous deployment job - deploy to AKS test namespace
# ==================================================================================
deploy-k8s-test:
name: Deploy to Test Environment
env:
NAMESPACE: test
environment:
name: AKS - test
url: "https://${{ env.NAMESPACE }}-${{ env.RELEASE_NAME }}.${{ env.DOMAIN }}/"
runs-on: ubuntu-latest
steps:
- name: "Checkout repo"
uses: actions/checkout@v1
- name: "Connect to AKS"
uses: azure/aks-set-context@v1
with:
creds: "${{ secrets.AZURE_CREDENTIALS }}" # Azure credentials
resource-group: "${{ env.RES_GRP }}"
cluster-name: "${{ env.AKS_NAME }}"
id: login
- name: "Helm dep update"
run: |
helm repo add stable https://charts.helm.sh/stable
helm dep update kubernetes/helm/smilr
- name: "Helm install release"
run: |
helm upgrade $NAMESPACE-$RELEASE_NAME kubernetes/helm/smilr --install --namespace $NAMESPACE --set "registryPrefix=$ACR_NAME.azurecr.io/,dataApi.imageTag=$IMAGE_TAG,frontend.imageTag=$IMAGE_TAG,ingress.domainSuffix=$DOMAIN,ingress.certName=$CERT"
# ==================================================================================
# Integration API tests
# ==================================================================================
run-api-tests:
name: Run API Tests
needs: deploy-k8s-test
env:
NAMESPACE: test
environment:
name: AKS - test
url: "https://${{ env.NAMESPACE }}-${{ env.RELEASE_NAME }}.${{ env.DOMAIN }}/"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Wait for API to be ready
run: etc/bash/url-check.sh -u https://$NAMESPACE-$RELEASE_NAME.$DOMAIN/api/info -t 60 -c 2
# Run the tests inside a container with Newman
- name: Run API tests with Postman/newman
uses: docker://postman/newman:ubuntu
with:
args: run /github/workspace/testing/postman/smilr-api-tests.json /
--timeout 180000 /
--global-var smilr-api-host="${{ env.NAMESPACE }}-${{ env.RELEASE_NAME }}.${{ env.DOMAIN }}"
# ==================================================================================
# Continuous deployment job - deploy to AKS staging namespace
# ==================================================================================
deploy-k8s-staging:
name: Deploy to Staging Environment
needs: run-api-tests
env:
NAMESPACE: staging
environment:
name: AKS - staging
url: "https://${{ env.NAMESPACE }}-${{ env.RELEASE_NAME }}.${{ env.DOMAIN }}/"
runs-on: ubuntu-latest
steps:
- name: "Checkout repo"
uses: actions/checkout@v1
- name: "Connect to AKS"
uses: azure/aks-set-context@v1
with:
creds: "${{ secrets.AZURE_CREDENTIALS }}" # Azure credentials
resource-group: "${{ env.RES_GRP }}"
cluster-name: "${{ env.AKS_NAME }}"
id: login
- name: "Helm dep update"
run: |
helm repo add stable https://charts.helm.sh/stable
helm dep update kubernetes/helm/smilr
- name: "Helm install release"
run: |
helm upgrade $NAMESPACE-$RELEASE_NAME kubernetes/helm/smilr --install --namespace $NAMESPACE --set "registryPrefix=$ACR_NAME.azurecr.io/,dataApi.imageTag=$IMAGE_TAG,frontend.imageTag=$IMAGE_TAG,ingress.domainSuffix=$DOMAIN,ingress.certName=$CERT"
# ==================================================================================
# Simple load test
# ==================================================================================
run-load-test:
name: Run Load Test
needs: deploy-k8s-staging
env:
NAMESPACE: staging
K6_VER: "0.29.0"
environment:
name: AKS - staging
url: "https://${{ env.NAMESPACE }}-${{ env.RELEASE_NAME }}.${{ env.DOMAIN }}/"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Wait for API to be ready
run: etc/bash/url-check.sh -u https://$NAMESPACE-$RELEASE_NAME.$DOMAIN/api/info -t 60 -c 2
- name: Download k6 binary
run: |
wget -q https://github.com/loadimpact/k6/releases/download/v${K6_VER}/k6-v${K6_VER}-linux64.tar.gz
tar -xzf k6-v${{ env.K6_VER }}-linux64.tar.gz
working-directory: testing/loadtest
- name: Run loadtest with k6
run: |
./k6-v${K6_VER}-linux64/k6 run -q \
-e API_HOST=https://${{ env.NAMESPACE }}-${{ env.RELEASE_NAME }}.${{ env.DOMAIN }} \
-e FRONT_HOST=https://${{ env.NAMESPACE }}-${{ env.RELEASE_NAME }}.${{ env.DOMAIN }} \
loadtest.js --out json=result.json
working-directory: testing/loadtest