-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevfile.yaml
204 lines (199 loc) · 7.03 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
schemaVersion: 2.2.0
metadata:
name: workshop-performance-monitoring-apps
components:
### Workspace Tools Container
- name: tools
container:
image: quay.io/redhat_na_ssa/universal-developer-image:ubi8-latest # our fork - 2.0GB compressed
#image: quay.io/devfile/universal-developer-image:latest# upstream - 3.7GB compressed
#image: registry.redhat.io/devspaces/udi-rhel8:latest #1.7GB compressed
#image: registry.redhat.io/devspaces/udi-rhel8@sha256:d18f22ef1aa2e5d1da4e3356ee1fc8fa59f795cdc3ab9d54c666054fbcfecd8f
env:
- name: QUARKUS_HTTP_HOST
value: 0.0.0.0
- name: USE_JAVA17
value: 'true'
endpoints:
- exposure: public
name: quarkus-app
protocol: https
targetPort: 8701
path: /quarkus
- exposure: public
name: micronaut-app
protocol: https
targetPort: 8702
path: /micronaut
- exposure: public
name: springboot-app
protocol: https
targetPort: 8703
path: /springboot
volumeMounts:
- name: m2
path: /home/user/.m2
memoryLimit: 6Gi
memoryRequest: 2Gi
cpuRequest: '1'
cpuLimit: '3'
mountSources: true
### volumes
- name: m2
volume:
size: 3G
commands:
### Quarkus inner-loop commands
- id: quarkus-package-jvm
exec:
label: '01: Quarkus - JVM Package'
commandLine: './mvnw clean package -DskipTests -Dquarkus.container-image.build=false -Dquarkus.container-image.builder=openshift'
component: tools
group:
isDefault: true
kind: build
workingDir: '${PROJECT_SOURCE}/quarkus-app/'
- id: quarkus-test
exec:
label: '02: Quarkus - Test'
commandLine: './mvnw test'
component: tools
group:
isDefault: true
kind: build
workingDir: '${PROJECT_SOURCE}/quarkus-app/'
- id: quarkus-start-dev
exec:
label: '03: Quarkus - Start in dev mode (Hot reload + debug)'
commandLine: './mvnw compile quarkus:dev -DskipTests -Dquarkus.container-image.build=false -Dquarkus.container-image.builder=openshift'
component: tools
group:
isDefault: true
kind: run
workingDir: '${PROJECT_SOURCE}/quarkus-app/'
### Micronaut inner-loop commands
- id: mn-package-jvm
exec:
label: '04: Micronaut - JVM Package'
commandLine: './mvnw clean package -DskipTests'
component: tools
group:
isDefault: true
kind: build
workingDir: '${PROJECT_SOURCE}/micronaut-app/'
- id: mn-start-dev
exec:
label: '05: Micronaut - Start in dev mode'
commandLine: './mvnw compile -Dmicronaut.environments=dev mn:run'
component: tools
group:
isDefault: true
kind: run
workingDir: '${PROJECT_SOURCE}/micronaut-app/'
- id: mn-test
exec:
label: '06: Micronaut - Test'
commandLine: './mvnw test'
component: tools
group:
isDefault: true
kind: run
workingDir: '${PROJECT_SOURCE}/micronaut-app/'
### SpringBoot inner-loop commands
- id: sb-package-jvm
exec:
label: '07: SpringBoot - JVM Package'
commandLine: './mvnw clean package -DskipTests'
component: tools
group:
isDefault: true
kind: build
workingDir: '${PROJECT_SOURCE}/springboot-app/'
- id: sb-start-dev
exec:
label: '08: SpringBoot - Start in dev mode'
commandLine: './mvnw compile spring-boot:run -Dspring.profiles.active=development'
component: tools
group:
isDefault: true
kind: run
workingDir: '${PROJECT_SOURCE}/springboot-app/'
- id: sb-test
exec:
label: '09: SpringBoot - Test'
commandLine: './mvnw test'
component: tools
group:
isDefault: true
kind: run
workingDir: '${PROJECT_SOURCE}/springboot-app/'
### Common commands
- id: show-app-routes
exec:
label: '10: Show Hyperfoil and Apps Routes'
component: "tools"
commandLine: |
clear
echo
oc get route hyperfoil-instance --ignore-not-found=true -n "$(oc whoami)-hyperfoil" \
-o jsonpath="{'\n\nHYPERFOIL_CONTROLLER_URL: '}{'https://'}{.status.ingress[0].host}{'\n'}"
oc get rt quarkus-app --ignore-not-found=true -n "$(oc whoami)-staging" \
-o jsonpath="{'\nQUARKUS_APP_URL: '}{.status.address.url}{'\n'}{'APP_CONTEXT_PATH: /quarkus \n\n'}"
oc get rt micronaut-app --ignore-not-found=true -n "$(oc whoami)-staging" \
-o jsonpath="{'\nMICRONAUT_APP_URL: '}{.status.address.url}{'\n'}{'APP_CONTEXT_PATH: /micronaut \n\n'}"
oc get rt springboot-app --ignore-not-found=true -n "$(oc whoami)-staging" \
-o jsonpath="{'\nSPRINGBOOT_APP_URL: '}{.status.address.url}{'\n'}{'APP_CONTEXT_PATH: /springboot \n\n'}"
- id: enable-cpu-auto-scaling
exec:
label: '11: Enable CPU based auto-scaling'
component: "tools"
commandLine: |
${PROJECT_SOURCE}/scripts/enable-auto-scaling.sh cpu 20
- id: enable-memory-auto-scaling
exec:
label: '12: Enable Memory based auto-scaling'
component: "tools"
commandLine: |
${PROJECT_SOURCE}/scripts/enable-auto-scaling.sh memory 400
- id: create-registry-push-secret
exec:
label: '13: Link Secret to Pipeline SA'
component: "tools"
commandLine: |
clear
oc secrets link pipeline quay-secret --for=pull,mount -n "$(oc whoami)-cicd"
- id: oc-login
exec:
label: '98: OC Login'
component: "tools"
commandLine: |
clear
echo
echo "current user: $(oc whoami)"
echo "current project: $(oc project)"
echo
oc login -u $(echo $DEVWORKSPACE_NAMESPACE | cut -d'-' -f 1) "https://$KUBERNETES_SERVICE_HOST:443" --insecure-skip-tls-verify=true
oc project $DEVWORKSPACE_NAMESPACE
- id: init-setup
exec:
label: '99: initial setup'
component: "tools"
workingDir: "${PROJECT_SOURCE}"
commandLine: |
#if sdkman is present use it
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh" && sdk default java 17.0.7-tem
#if no sdkaman do it manually
#[[ -d /usr/lib/jvm/java-17-openjdk ]] && rm -rf ${HOME}/.java/current/* && ln -s /usr/lib/jvm/java-17-openjdk/* ${HOME}/.java/current
#copy maven settings pointing to in-cluster nexus mirror
[[ -s "$PROJECT_SOURCE/settings.xml" ]] && cp -v $PROJECT_SOURCE/settings.xml $HOME/.m2/
#setup git default config
git config --local credential.helper store
git config --local pull.rebase true
git config --local fetch.prune true
git config --local diff.colorMoved zebra
echo "source /usr/share/bash-completion/completions/git" >> /home/user/.bashrc
oc completion bash > /home/user/.oc_bash_completion
echo "source /home/user/.oc_bash_completion" >> /home/user/.bashrc
events:
postStart:
- init-setup # <== Start of the workspace happens after this command is completed