-
Notifications
You must be signed in to change notification settings - Fork 28
/
devfile.yaml
307 lines (254 loc) · 11.1 KB
/
devfile.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
metadata:
name: wksp-cloud-native
attributes:
extensions.ignoreRecommendations: 'true'
projects:
- name: workshop
source:
location: 'https://github.com/mcouliba/cloud-native-workshop.git'
type: github
branch: '5.1'
components:
- type: chePlugin
id: redhat/java11/latest
preferences:
java.server.launchMode: Standard
java.autobuild.enabled: false
- type: dockerimage
image: 'quay.io/mcouliba/workshop-tools:5.0'
alias: workshop-tools
memoryLimit: "3072M"
mountSources: true
env:
- name: MAVEN_OPTS
value: '-Xmx2048m -Duser.home=/home/developer'
- name: MAVEN_MIRROR_URL
value: http://nexus.opentlc-shared.svc:8081/repository/maven-all-public
endpoints:
- name: 8080-port
port: 8080
attributes:
protocol: http
- name: 9000-port
port: 9000
attributes:
protocol: http
- name: 5005-port
port: 5005
attributes:
protocol: http
public: 'false'
volumes:
- name: kubefolder
containerPath: /home/developer/.kube
apiVersion: 1.0.0
commands:
- name: 'OpenShift - Login'
actions:
- command: >-
odo login $(oc whoami --show-server) --username=${CHE_WORKSPACE_NAMESPACE} --password=openshift --insecure-skip-tls-verify
type: exec
workdir: /projects/workshop
component: workshop-tools
- name: 'OpenShift - Create Development Project'
actions:
- command: >-
odo project create my-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop
component: workshop-tools
- name: 'Inventory - Compile (Dev Mode)'
actions:
- command: >-
[[ ! -z "$(ps aux | grep -v grep | grep "compile quarkus:dev" | awk '{print $2}')" ]] && echo '!! Application already running in Dev Mode !!' || mvn compile quarkus:dev -Ddebug=false
type: exec
workdir: /projects/workshop/labs/inventory-quarkus
component: workshop-tools
- name: 'Inventory - Build'
actions:
- command: >-
mvn clean package -DskipTests
type: exec
workdir: /projects/workshop/labs/inventory-quarkus
component: workshop-tools
- name: 'Inventory - Create Component'
actions:
- command: >-
odo component create java:11 inventory --app coolstore --binary target/inventory-quarkus-1.0.0-SNAPSHOT-runner.jar --s2i --project my-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop/labs/inventory-quarkus
component: workshop-tools
- name: 'Inventory - Push'
actions:
- command: >-
odo push
type: exec
workdir: /projects/workshop/labs/inventory-quarkus
component: workshop-tools
- name: 'Inventory - Expose'
actions:
- command: >-
odo url create inventory --port 8080
type: exec
workdir: /projects/workshop/labs/inventory-quarkus
component: workshop-tools
- name: 'Catalog - Build'
actions:
- command: >-
mvn clean package -DskipTests
type: exec
workdir: /projects/workshop/labs/catalog-spring-boot
component: workshop-tools
- name: 'Catalog - Run'
actions:
- command: >-
mvn spring-boot:run
type: exec
workdir: /projects/workshop/labs/catalog-spring-boot
component: workshop-tools
- name: 'Catalog - Create Component'
actions:
- command: >-
odo component create java:11 catalog --app coolstore --binary target/catalog-1.0-SNAPSHOT.jar --s2i --project my-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop/labs/catalog-spring-boot
component: workshop-tools
- name: 'Catalog - Expose'
actions:
- command: >-
odo url create catalog --port 8080
type: exec
workdir: /projects/workshop/labs/catalog-spring-boot
component: workshop-tools
- name: 'Catalog - Push'
actions:
- command: >-
odo push
type: exec
workdir: /projects/workshop/labs/catalog-spring-boot
component: workshop-tools
- name: 'Gateway - Create Component'
actions:
- command: >-
odo component create dotnet:3.1-ubi8 gateway --app coolstore --s2i --project my-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop/labs/gateway-dotnet
component: workshop-tools
- name: 'Gateway - Expose'
actions:
- command: >-
odo url create gateway --port 8080
type: exec
workdir: /projects/workshop/labs/gateway-dotnet
component: workshop-tools
- name: 'Gateway - Push'
actions:
- command: >-
odo push
type: exec
workdir: /projects/workshop/labs/gateway-dotnet
component: workshop-tools
- name: 'Catalog - Link to Gateway'
actions:
- command: >-
odo link catalog --port 8080 --component gateway
type: exec
workdir: /projects/workshop/labs/gateway-dotnet
component: workshop-tools
- name: 'Inventory - Link to Gateway'
actions:
- command: >-
odo link inventory --port 8080 --component gateway
type: exec
workdir: /projects/workshop/labs/gateway-dotnet
component: workshop-tools
- name: 'Catalog - Generate Traffic'
actions:
- command: >-
for i in {1..60}; do if [ $(curl -s -w "%{http_code}" -o /dev/null http://catalog-coolstore.my-project${CHE_WORKSPACE_NAMESPACE#user}.svc:8080/actuator/health) == "200" ]; then MSG="\\033[0;32mThe request to Catalog Service has succeeded\\033[0m"; else MSG="\\033[0;31mERROR - The request to Catalog Service has failed\\033[0m"; fi;echo -e $MSG;sleep 2s; done
type: exec
workdir: /projects/workshop/labs/catalog-spring-boot
component: workshop-tools
- name: 'Catalog - Add PodAffinity'
actions:
- command: >-
oc patch dc/catalog-coolstore -n my-project${CHE_WORKSPACE_NAMESPACE#user} --patch '{"spec": {"template": {"spec": {"affinity": {"podAffinity": {"requiredDuringSchedulingIgnoredDuringExecution": [{"labelSelector": { "matchExpressions": [{"key" : "deploymentconfig", "operator" : "In", "values": ["catalog-coolstore"]}]}, "topologyKey" : "kubernetes.io/hostname"}]}}}}}}'
type: exec
workdir: /projects/workshop/labs/catalog-spring-boot
component: workshop-tools
- name: 'Probes - Configure Gateway & Web'
actions:
- command: >-
oc project my-project${CHE_WORKSPACE_NAMESPACE#user}; oc set probe dc/gateway-coolstore --liveness --readiness --period-seconds=5 --get-url=http://:8080/health;oc set probe deployment/web-coolstore --liveness --readiness --period-seconds=5 --get-url=http://:8080/;echo "Health Probes Done"
type: exec
workdir: /projects/workshop
component: workshop-tools
- name: 'Inventory - Mount ConfigMap'
actions:
- command: >-
oc set volume dc/inventory-coolstore --add --configmap-name=inventory --mount-path=/deployments/config -n my-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop/labs/inventory-quarkus
component: workshop-tools
- name: 'Gateway - Generate Traffic'
actions:
- command: >-
./gateway_generate_traffic.sh cn-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop/.tasks
component: workshop-tools
- name: 'Inner Loop - Deploy Coolstore'
actions:
- command: >-
./inner_loop_deploy_coolstore.sh my-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop/.tasks
component: workshop-tools
- name: 'Inventory - Commit'
actions:
- command: >-
git init; git remote add origin http://gitea-server.gitea.svc:3000/${CHE_WORKSPACE_NAMESPACE}/inventory-quarkus.git; git add *; git commit -m "Initial"; git push http://${CHE_WORKSPACE_NAMESPACE}:[email protected]:3000/${CHE_WORKSPACE_NAMESPACE}/inventory-quarkus.git
type: exec
workdir: /projects/workshop/labs/inventory-quarkus
component: workshop-tools
- name: 'GitOps - Export Coolstore'
actions:
- command: >-
./gitops_export_coolstore.sh my-project${CHE_WORKSPACE_NAMESPACE#user} cn-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop/.tasks
component: workshop-tools
- name: 'Pipeline - Deploy Coolstore'
actions:
- command: >-
oc project cn-project${CHE_WORKSPACE_NAMESPACE#user} && ./pipeline_deploy_coolstore.sh cn-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop/.tasks
component: workshop-tools
- name: 'GitOps - Commit Inventory'
actions:
- command: >-
git init; git remote add origin http://gitea-server.gitea.svc:3000/${CHE_WORKSPACE_NAMESPACE}/inventory-gitops.git 2> /dev/null; git add *; git commit -m "Initial Inventory GitOps"; git push http://${CHE_WORKSPACE_NAMESPACE}:[email protected]:3000/${CHE_WORKSPACE_NAMESPACE}/inventory-gitops.git
type: exec
workdir: /projects/workshop/labs/gitops/inventory-coolstore
component: workshop-tools
- name: 'GitOps - Commit & Configure Coolstore'
actions:
- command: >-
./gitops_commit_configure_coolstore.sh ${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop/.tasks
component: workshop-tools
- name: 'Service Mesh - Deploy Catalog and Gateway'
actions:
- command: >-
oc patch dc/catalog-coolstore --patch '{"spec": {"template": {"metadata": {"annotations": {"sidecar.istio.io/inject": "true"}}}}}' -n cn-project${CHE_WORKSPACE_NAMESPACE#user} && oc rollout latest dc/catalog-coolstore -n cn-project${CHE_WORKSPACE_NAMESPACE#user} && oc patch dc/gateway-coolstore --patch '{"spec": {"template": {"metadata": {"annotations": {"sidecar.istio.io/inject": "true"}}}}}' -n cn-project${CHE_WORKSPACE_NAMESPACE#user} && oc rollout latest dc/gateway-coolstore -n cn-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
component: workshop-tools
- name: 'OpenShift - Cleanup'
actions:
- command: >-
git checkout .; git clean -fd; git clean -f; oc delete project my-project${CHE_WORKSPACE_NAMESPACE#user}; oc delete deployment,deploymentconfig,buildconfig,imagestream,route,secret,configmap,pvc,service,pipeline,pipelinerun --all --namespace cn-project${CHE_WORKSPACE_NAMESPACE#user}
type: exec
workdir: /projects/workshop
component: workshop-tools