-
Notifications
You must be signed in to change notification settings - Fork 0
/
devfile.yaml
291 lines (250 loc) · 9.65 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
apiVersion: 1.0.0
metadata:
generateName: postit-app-
projects:
- source:
type: git
location: 'https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app'
name: postit-app
components:
- alias: quarkus-backend-dev
type: dockerimage
image: quay.io/quarkus/centos-quarkus-maven:20.0.0-java8
memoryLimit: 5Gi
command: ['sleep']
args: ['infinity']
mountSources: true
env:
- name: MAVEN_OPTS
value: '-Dmaven.repo.local=/.m2/repository'
- name: username
value: 'user'
- name: password
value: 'password'
- name: admin_password
value: 'password'
- name: uri
value: 'mongodb://localhost'
endpoints:
- name: 'quarkus-dev'
port: 8080
volumes:
- name: .m2
containerPath: /.m2
- mountSources: true
memoryLimit: 64M
type: dockerimage
image: quay.io/sunix/postit-app-dev-data
alias: data
volumes:
- name: .m2
containerPath: /work/volumes/.m2
- alias: node-frontend-dev
mountSources: true
image: 'quay.io/eclipse/che-nodejs8-centos:7.2.0'
memoryLimit: 768Mi
type: dockerimage
endpoints:
- name: '3000-tcp'
port: 3000
env:
- name: FRONTEND_PORT
value: '3000'
- alias: quarkus-backend-native-prod
type: dockerimage
image: quay.io/quarkus/ubi-quarkus-native-image:19.2.0.1
memoryLimit: 32M
mountSources: true
command: ['tail']
args: ['-f', '/dev/null']
endpoints:
- name: '8080-tcp'
port: 8080
env:
- name: username
value: 'user'
- name: password
value: 'password'
- name: admin_password
value: 'password'
- name: uri
value: 'mongodb://localhost'
- alias: mongo
type: dockerimage
image: centos/mongodb-34-centos7
memoryLimit: 512Mi
env:
- name: MONGODB_USER
value: user
- name: MONGODB_PASSWORD
value: password
- name: MONGODB_DATABASE
value: sampledb
- name: MONGODB_ADMIN_PASSWORD
value: password
- id: redhat/quarkus-java11/latest
type: chePlugin
- id: redhat/vscode-openshift-connector/latest
type: chePlugin
alias: vscode-openshift
- alias: git
type: dockerimage
image: sunix/git-devtools
mountSources: true
memoryLimit: 64M
args: ['sleep', 'infinity']
commands:
- name: start DEVMODE quarkus-backend
actions:
- type: exec
command: pkill java; mvn compile quarkus:dev
component: quarkus-backend-dev
workdir: /projects/postit-app/quarkus-backend
# - name: build JVM quarkus-backend
# actions:
# - type: exec
# command: pkill java; mvn package
# component: quarkus-backend-dev
# workdir: /projects/postit-app/quarkus-backend
- name: build NATIVE quarkus-backend
actions:
- type: exec
command: pkill java; mvn package -Pnative
component: quarkus-backend-dev
workdir: /projects/postit-app/quarkus-backend
- name: start NATIVE quarkus-backend
actions:
- type: exec
command: ./quarkus-backend-1.0.0-SNAPSHOT-runner -Dquarkus.http.host=0.0.0.0
component: quarkus-backend-native-prod
workdir: /projects/postit-app/quarkus-backend/target
- name: connect java debugger quarkus-backend
actions:
- type: vscode-launch
referenceContent: |
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Attach) - Remote",
"request": "attach",
"hostName": "localhost",
"port": 5005
}]
}
# - name: build PROD node-frontend
# actions:
# - type: exec
# command: tar zxvf /projects/local/node_modules.tar.gz ; rm /projects/local/node_modules.tar.gz ; npm install
# component: node-frontend-dev
# workdir: /projects/postit-app/node-frontend/
- name: start DEVMODE node-frontend
actions:
- type: exec
command: npm run devmode
component: node-frontend-dev
workdir: /projects/postit-app/node-frontend/
- name: start PROD node-frontend
actions:
- type: exec
command: npm start
component: node-frontend-dev
workdir: /projects/postit-app/node-frontend/
- name: oc - deploy app (quarkus NATIVE) from github
actions:
- type: exec
command: |-
# mongodb
oc new-app -e MONGODB_USER=user -e MONGODB_PASSWORD=password -e MONGODB_DATABASE=sampledb -e MONGODB_ADMIN_PASSWORD=password centos/mongodb-36-centos7 --name=mongo
# s2i quarkus app from source
oc new-app quay.io/quarkus/ubi-quarkus-native-s2i:20.0.0-java8~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --name=quarkus-backend --context-dir=quarkus-backend -e uri=mongodb://mongo -e username=user -e password=password
# s2i node frontend from source
oc new-app nodejs~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --context-dir=node-frontend --name=node-frontend -e PORT=8080 -e COMPONENT_QUARKUS_BACKEND_HOST=quarkus-backend
oc expose svc/node-frontend
# quarkus native build need more cpu and memory
# wait for quakus-backend build to start and cancel it to reconfigure it
for i in 1 2 3 4 5 6 7 8 9; do
pods="$(oc get build -o go-template='{{range .items}}{{$bc := index .metadata.annotations "openshift.io/build-config.name"}}{{$status := index .status.phase}}{{if eq $bc "quarkus-backend"}}{{if eq $status "Running"}}{{.metadata.name}}{{"\t"}}{{.status.phase}}{{"\n"}}{{end}}{{end}}{{end}}')";
echo $pods;
if [ -n "$pods" ]; then
break;
fi
echo "Waiting for quarkus-backend build to be ready...";
sleep "2";
done
oc cancel-build bc/quarkus-backend
oc patch bc/quarkus-backend -p '{"spec":{"resources":{"limits":{"cpu":"6", "memory":"6Gi"}}}}'
oc start-build quarkus-backend
oc expose svc/quarkus-backend
# logs
oc logs -f bc/quarkus-backend
oc logs -f bc/node-frontend
echo node-frontend url http://$(oc get route node-frontend --template='{{ .spec.host }}')
component: vscode-openshift
workdir: /projects/postit-app/node-frontend/
- name: oc - deploy app (quarkus JVM) from github
actions:
- type: exec
command: |-
# mongodb
oc new-app -e MONGODB_USER=user -e MONGODB_PASSWORD=password -e MONGODB_DATABASE=sampledb -e MONGODB_ADMIN_PASSWORD=password centos/mongodb-36-centos7 --name=mongo
# s2i quarkus app from source
oc new-app java~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --name=quarkus-backend --context-dir=quarkus-backend -e uri=mongodb://mongo -e username=user -e password=password --env=JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0"
oc expose svc/quarkus-backend
# s2i node frontend from source
oc new-app nodejs~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --context-dir=node-frontend --name=node-frontend -e PORT=8080 -e COMPONENT_QUARKUS_BACKEND_HOST=quarkus-backend
oc expose svc/node-frontend
oc logs -f bc/quarkus-backend
oc logs -f bc/node-frontend
echo node-frontend url http://$(oc get route node-frontend --template='{{ .spec.host }}')
component: vscode-openshift
workdir: /projects/postit-app/node-frontend/
- name: oc - redeploy quarkus-backend (from local sources)
actions:
- type: exec
command: |-
oc start-build quarkus-backend --from-dir=.
oc logs -f bc/quarkus-backend
component: vscode-openshift
workdir: /projects/postit-app/
- name: oc - redeploy node-frontend (from local sources)
actions:
- type: exec
command: |-
oc start-build node-frontend --from-dir=.
oc logs -f bc/node-frontend
component: vscode-openshift
workdir: /projects/postit-app/
- name: oc - scale node-frontend
actions:
- type: exec
command: |-
echo "Scale node-frontend. Enter the number of desired replicas:";
read replicas;
oc scale dc/node-frontend --replicas=${replicas}
component: vscode-openshift
workdir: /projects/postit-app/
- name: oc - scale quarkus-backend
actions:
- type: exec
command: |-
echo "Scale quarkus-frontend. Enter the number of desired replicas:";
read replicas;
oc scale dc/quarkus-backend --replicas=${replicas}
component: vscode-openshift
workdir: /projects/postit-app/
- name: oc - get node-frontend URL
actions:
- type: exec
command: |-
echo node-frontend url http://$(oc get route node-frontend --template='{{ .spec.host }}')
component: vscode-openshift
workdir: /projects/postit-app/node-frontend/
- name: oc login
actions:
- type: exec
command: |-
rm oc; curl https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz -s | tar zxv && ./oc login --server=${KUBERNETES_SERVICE_HOST}:443
component: vscode-openshift
workdir: /tmp