forked from mcouliba/cloud-native-workshop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdevfile.yaml
319 lines (319 loc) · 15.7 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
307
308
309
310
311
312
313
314
315
316
317
318
319
metadata:
name: wksp-cloud-native
projects:
- name: workshop
source:
location: 'https://github.com/mcouliba/cloud-native-workshop.git'
type: github
branch: 'ocp4.6'
components:
- id: redhat/workshop-tools/4.6.0
type: chePlugin
alias: workshop-tools
env:
- name: MAVEN_OPTS
value: '-Xmx2048m -Duser.home=/home/theia'
- name: MAVEN_MIRROR_URL
value: http://nexus.opentlc-shared.svc:8081/repository/maven-all-public
volumes:
- name: kubefolder
containerPath: /home/theia/.kube
apiVersion: 1.0.0
commands:
- name: Configure tasks
actions:
- referenceContent: |
{
"tasks": [
{
"type": "che",
"label": "OpenShift - Login",
"command": "odo login $(oc whoami --show-server) --username=${CHE_WORKSPACE_NAMESPACE} --password=openshift --insecure-skip-tls-verify",
"target": {
"workingDir": "/projects/workshop",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "OpenShift - Create Development Project",
"command": "odo project create my-project${CHE_WORKSPACE_NAMESPACE#user}",
"target": {
"workingDir": "/projects/workshop",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Inventory - Compile (Dev Mode)",
"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",
"target": {
"workingDir": "/projects/workshop/labs/inventory-quarkus",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Inventory - Build",
"command": "mvn clean package -DskipTests",
"target": {
"workingDir": "/projects/workshop/labs/inventory-quarkus",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Inventory - Create Component",
"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}",
"target": {
"workingDir": "/projects/workshop/labs/inventory-quarkus",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Inventory - Push",
"command": "odo push",
"target": {
"workingDir": "/projects/workshop/labs/inventory-quarkus",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Inventory - Expose",
"command": "odo url create inventory --port 8080",
"target": {
"workingDir": "/projects/workshop/labs/inventory-quarkus",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Catalog - Build",
"command": "mvn clean package -DskipTests",
"target": {
"workingDir": "/projects/workshop/labs/catalog-spring-boot",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Catalog - Run",
"command": "mvn spring-boot:run",
"target": {
"workingDir": "/projects/workshop/labs/catalog-spring-boot",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Catalog - Create Component",
"command": "odo component create java:11 catalog --app coolstore --binary target/catalog-1.0-SNAPSHOT.jar --s2i --project my-project${CHE_WORKSPACE_NAMESPACE#user}",
"target": {
"workingDir": "/projects/workshop/labs/catalog-spring-boot",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Catalog - Expose",
"command": "odo url create catalog --port 8080",
"target": {
"workingDir": "/projects/workshop/labs/catalog-spring-boot",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Catalog - Push",
"command": "odo push",
"target": {
"workingDir": "/projects/workshop/labs/catalog-spring-boot",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Gateway - Create Component",
"command": "odo component create dotnet gateway --app coolstore --s2i --project my-project${CHE_WORKSPACE_NAMESPACE#user}",
"target": {
"workingDir": "/projects/workshop/labs/gateway-dotnet",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Gateway - Expose",
"command": "odo url create gateway --port 8080",
"target": {
"workingDir": "/projects/workshop/labs/gateway-dotnet",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Gateway - Push",
"command": "odo push",
"target": {
"workingDir": "/projects/workshop/labs/gateway-dotnet",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Catalog - Link to Gateway",
"command": "odo link catalog --port 8080 --component gateway",
"target": {
"workingDir": "/projects/workshop/labs/gateway-dotnet",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Inventory - Link to Gateway",
"command": "odo link inventory --port 8080 --component gateway",
"target": {
"workingDir": "/projects/workshop/labs/gateway-dotnet",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Catalog - Generate Traffic",
"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",
"target": {
"workingDir": "/projects/workshop/labs/catalog-spring-boot",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Catalog - Add PodAffinity",
"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\"}]}}}}}}'",
"target": {
"workingDir": "/projects/workshop/labs/catalog-spring-boot",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Probes - Configure Gateway & Web",
"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\"",
"target": {
"workingDir": "/projects/workshop",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Inventory - Mount ConfigMap",
"command": "oc set volume dc/inventory-coolstore --add --configmap-name=inventory --mount-path=/deployments/config -n my-project${CHE_WORKSPACE_NAMESPACE#user}",
"target": {
"workingDir": "/projects/workshop/labs/inventory-quarkus",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Gateway - Generate Traffic",
"command": "./gateway_generate_traffic.sh cn-project${CHE_WORKSPACE_NAMESPACE#user}",
"target": {
"workingDir": "/projects/workshop/.tasks",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Inner Loop - Deploy Coolstore",
"command": "./inner_loop_deploy_coolstore.sh my-project${CHE_WORKSPACE_NAMESPACE#user}",
"target": {
"workingDir": "/projects/workshop/.tasks",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Inventory - Commit",
"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",
"target": {
"workingDir": "/projects/workshop/labs/inventory-quarkus",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "GitOps - Export Coolstore",
"command": "./gitops_export_coolstore.sh my-project${CHE_WORKSPACE_NAMESPACE#user} cn-project${CHE_WORKSPACE_NAMESPACE#user}",
"target": {
"workingDir": "/projects/workshop/.tasks",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Pipeline - Deploy Coolstore",
"command": "oc project cn-project${CHE_WORKSPACE_NAMESPACE#user} && ./pipeline_deploy_coolstore.sh cn-project${CHE_WORKSPACE_NAMESPACE#user}",
"target": {
"workingDir": "/projects/workshop/.tasks",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "GitOps - Commit Inventory",
"command": "git init; git remote add origin http://gitea-server.gitea.svc:3000/${CHE_WORKSPACE_NAMESPACE}/gitops-cn-project.git 2> /dev/null; git add inventory*.yaml; git commit -m \"Initial Inventory GitOps\"; git push http://${CHE_WORKSPACE_NAMESPACE}:[email protected]:3000/${CHE_WORKSPACE_NAMESPACE}/gitops-cn-project.git",
"target": {
"workingDir": "/projects/workshop/labs/gitops",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "GitOps - Commit Coolstore",
"command": "git init; git remote add origin http://gitea-server.gitea.svc:3000/${CHE_WORKSPACE_NAMESPACE}/gitops-cn-project.git 2> /dev/null; git add *.yaml; git commit -m \"Initial Coolstore GitOps\"; git push http://${CHE_WORKSPACE_NAMESPACE}:[email protected]:3000/${CHE_WORKSPACE_NAMESPACE}/gitops-cn-project.git",
"target": {
"workingDir": "/projects/workshop/labs/gitops",
"component": "workshop-tools"
},
"problemMatcher": []
},
{
"type": "che",
"label": "Service Mesh - Deploy Catalog and Gateway",
"command": "oc patch dc/catalog-coolstore --patch '{\"spec\": {\"template\": {\"metadata\": {\"annotations\": {\"sidecar.istio.io/inject\": \"true\"}}}}}' -n cn-project${CHE_WORKSPACE_NAMESPACE#user}&& oc patch dc/catalog-coolstore --patch '{\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"catalog-coolstore\", \"command\" : [\"/bin/bash\"], \"args\": [\"-c\", \"until $(curl -o /dev/null -s -I -f http://127.0.0.1:15000); do echo \\\"Waiting for Istio Sidecar...\\\"; sleep 1; done; sleep 10; /usr/local/s2i/run\"]}]}}}}' -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 patch dc/gateway-coolstore --patch '{\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"gateway-coolstore\", \"command\" : [\"/bin/bash\"], \"args\": [\"-c\", \"until $(curl -o /dev/null -s -I -f http://127.0.0.1:15000); do echo \\\"Waiting for Istio Sidecar...\\\"; sleep 1; done; sleep 10; /usr/local/s2i/run\"]}]}}}}' -n cn-project${CHE_WORKSPACE_NAMESPACE#user} && oc rollout latest dc/gateway-coolstore -n cn-project${CHE_WORKSPACE_NAMESPACE#user}",
"target": {
"component": "workshop-tools"
},
"problemMatcher": []
}
]
}
type: vscode-task