-
Notifications
You must be signed in to change notification settings - Fork 180
180 lines (177 loc) · 5.49 KB
/
deploy.yaml
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Build and deploy
on:
push:
branches:
- main
paths:
- 'iac/**'
- 'src/**'
- '.github/workflows/**'
workflow_dispatch:
env:
CLUSTER_NAME: petspotr
REGISTRY_ADDRESS: petspotrspvxk42ak6y3u.azurecr.io
jobs:
infra:
name: Deploy Infrastructure
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy Infrastructure
run: |
az deployment group create \
--subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--template-file iac/infra.bicep
config:
name: Deploy configuration and secrets
runs-on: ubuntu-latest
needs: infra
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy secrets
run: |
az deployment group create \
--subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--template-file iac/config.bicep
helm:
name: Install Helm Charts
runs-on: ubuntu-latest
needs: infra
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Get AKS Credentials
run: |
az aks get-credentials \
--subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--name ${{ env.CLUSTER_NAME }}
- name: Deploy Keda Chart
run: |
helm repo add kedacore https://kedacore.github.io/charts
helm repo update
helm upgrade keda kedacore/keda --install --version=2.9.4 --namespace keda --create-namespace --wait
- name: Deploy Dapr Chart
run: |
helm repo add dapr https://dapr.github.io/helm-charts/
helm repo update
helm upgrade dapr dapr/dapr --install --version=1.10 --namespace dapr-system --create-namespace --wait
keda:
name: Install KEDA scalers
runs-on: ubuntu-latest
needs:
- helm
- config
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Get AKS Credentials
run: |
az aks get-credentials \
--subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--name ${{ env.CLUSTER_NAME }}
- name: Deploy KEDA scalers
run: |
kubectl apply -f iac/keda/scaler-servicebus.yaml
dapr:
name: Install Dapr components
runs-on: ubuntu-latest
needs:
- helm
- config
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Get AKS Credentials
run: |
az aks get-credentials \
--subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--name ${{ env.CLUSTER_NAME }}
- name: Deploy Dapr components
run: |
kubectl apply -f iac/dapr/azure/images.yaml
kubectl apply -f iac/dapr/azure/pubsub.yaml
kubectl apply -f iac/dapr/azure/pets.yaml
containers:
name: Build and publish Docker containers
runs-on: ubuntu-latest
needs: infra
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Login to ACR
run: |
az acr login --name ${{ env.REGISTRY_ADDRESS }}
- name: Build and Push Backend
uses: docker/build-push-action@v2
with:
push: true
tags: |
${{ env.REGISTRY_ADDRESS }}/backend:latest
file: src/backend/Dockerfile
context: src/backend
- name: Build and Push Frontend
uses: docker/build-push-action@v2
with:
push: true
tags: |
${{ env.REGISTRY_ADDRESS }}/frontend:latest
file: src/frontend/Dockerfile
context: src/frontend
app:
name: Deploy PetSpotR application
runs-on: ubuntu-latest
needs:
- containers
- config
- dapr
- keda
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Get AKS Credentials
run: |
az aks get-credentials \
--subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--name ${{ env.CLUSTER_NAME }}
- name: Deploy Application
run: |
az deployment group create \
--subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--template-file iac/app.bicep \