-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
202 lines (189 loc) · 5.84 KB
/
cloudbuild.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
timeout: 1200s
substitutions:
_CUSTOM_REGION: europe-west3-a
_CUSTOM_CLUSTER: denolte
_CUSTOM_BUILDTARGET: prod
steps:
# PREPARATION of kubectl and helm
- id: Configure kubectl
name: gcr.io/cloud-builders/kubectl
args:
- cluster-info
env:
- CLOUDSDK_COMPUTE_REGION=$_CUSTOM_REGION
- CLOUDSDK_CONTAINER_CLUSTER=$_CUSTOM_CLUSTER
- KUBECONFIG=/workspace/.kube/config
- id: Add jetstack repository for cert-manager
name: gcr.io/$PROJECT_ID/helm
args:
- repo
- add
- jetstack
- https://charts.jetstack.io
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
- id: Add traefik repository for traefik
name: gcr.io/$PROJECT_ID/helm
args:
- repo
- add
- traefik
- https://containous.github.io/traefik-helm-chart
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
- id: Add bitnami repository for mongodb
name: gcr.io/$PROJECT_ID/helm
args:
- repo
- add
- bitnami
- https://charts.bitnami.com/bitnami
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
- id: Add stable repository for envoy
name: gcr.io/$PROJECT_ID/helm
args:
- repo
- add
- stable
- https://kubernetes-charts.storage.googleapis.com/
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
# Provide secrets
- id: Acquire secrets from SecretManager
name: gcr.io/cloud-builders/gcloud
entrypoint: 'bash'
args:
- -c
- |
mkdir charts/cert-manager/kustomize/$${BUILDTARGET}/secrets
mkdir charts/mongodb/kustomize/$${BUILDTARGET}/secrets
mkdir charts/schedulytics-grpc-server/kustomize/$${BUILDTARGET}/secrets
gcloud secrets versions access latest --secret=schedulytics-cert-manager-sa > charts/cert-manager/kustomize/$${BUILDTARGET}/secrets/key.json
gcloud secrets versions access latest --secret=schedulytics-mongodb-root-password > charts/mongodb/kustomize/$${BUILDTARGET}/secrets/schedulytics-mongodb-root-password
gcloud secrets versions access latest --secret=schedulytics-mongodb-user-password > charts/mongodb/kustomize/$${BUILDTARGET}/secrets/schedulytics-mongodb-user-password
gcloud secrets versions access latest --secret=schedulytics-mongodb-user-password > charts/schedulytics-grpc-server/kustomize/$${BUILDTARGET}/secrets/schedulytics-mongodb-user-password
env:
- BUILDTARGET=$_CUSTOM_BUILDTARGET
# Apply CRDs because Helm template can lead do validation issues (client API takes time to invalidate cache and might break deployments)
# Also CRDs cannot be templated and thus do not need the rendering
- id: Deploy CRDs
name: gcr.io/$PROJECT_ID/helm
entrypoint: /bin/bash
args:
- -c
- |
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v0.15.1/cert-manager.crds.yaml
curl https://api.github.com/repos/containous/traefik-helm-chart/contents/traefik/crds | jq -r .[].download_url | xargs -L 1 kubectl apply --validate=false -f
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
- BUILDTARGET=$_CUSTOM_BUILDTARGET
# Templating via Helm
- id: Deploy cert-manager
name: gcr.io/$PROJECT_ID/helm
entrypoint: /bin/bash
dir: charts/cert-manager
args:
- -c
- >
helm upgrade cert-manager
--install
--create-namespace
--namespace cert-manager
-f values.yaml
--version v0.15.1
--skip-crds
--post-renderer /workspace/build/kustomize.py
jetstack/cert-manager
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
- BUILDTARGET=$_CUSTOM_BUILDTARGET
- id: Deploy traefik
name: gcr.io/$PROJECT_ID/helm
entrypoint: /bin/bash
dir: charts/traefik
args:
- -c
- >
helm upgrade traefik
--install
--create-namespace
--namespace traefik
-f values.yaml
--skip-crds
--post-renderer /workspace/build/kustomize.py
traefik/traefik
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
- BUILDTARGET=$_CUSTOM_BUILDTARGET
- id: Deploy envoy
name: gcr.io/$PROJECT_ID/helm
entrypoint: /bin/bash
dir: charts/envoy
args:
- -c
- >
helm upgrade -i envoy
--create-namespace
--namespace schedulytics
-f values.yaml
stable/envoy
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
- id: Deploy mongodb
name: gcr.io/$PROJECT_ID/helm
entrypoint: /bin/bash
dir: charts/mongodb
args:
- -c
- >
helm upgrade -i mongodb
--create-namespace
--namespace schedulytics
-f values.yaml
--post-renderer /workspace/build/kustomize.py
bitnami/mongodb
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
- BUILDTARGET=$_CUSTOM_BUILDTARGET
- id: Deploy schedulytics-frontend
name: gcr.io/$PROJECT_ID/helm
entrypoint: /bin/bash
dir: charts/schedulytics-frontend
args:
- -c
- >
helm upgrade -i schedulytics-frontend
--create-namespace
--namespace schedulytics
-f values.yaml
.
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
- id: Deploy schedulytics-grpc-server
name: gcr.io/$PROJECT_ID/helm
entrypoint: /bin/bash
dir: charts/schedulytics-grpc-server
args:
- -c
- >
helm upgrade -i schedulytics-grpc-server
--create-namespace
--namespace schedulytics
-f values.yaml
--post-renderer /workspace/build/kustomize.py
.
env:
- KUBECONFIG=/workspace/.kube/config
- TILLERLESS=true
- BUILDTARGET=$_CUSTOM_BUILDTARGET