-
Notifications
You must be signed in to change notification settings - Fork 1
/
devspace.yaml
511 lines (477 loc) · 14.8 KB
/
devspace.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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
version: v2beta1
# `name` is required for v2beta1
name: vcluster-fs-syncer
# `vars` specifies variables which may be used as ${VAR_NAME} in devspace.yaml
vars:
# These env vars are passed in automatically by devenv
# ================================================
# ========== DO NOT REORDER THESE VARS! ==========
# ================================================
# The vars are used to switch service label selectors in profiles
# It's probably not the best approach, but it works well.
DEVENV_DEPLOY_APPNAME:
source: env
default: vcluster-fs-syncer
DEV_CONTAINER_EXECUTABLE: ${DEVENV_DEPLOY_APPNAME}
# ================================================
DEPLOY_TO_DEV_VERSION:
source: env
default: "latest"
DEVENV_DEPLOY_VERSION:
source: env
default: "latest"
# DEVENV_SYNC_BINARIES:
# false: Devspace is build machine that synchronizes source code and runs it
# true: Devspace synchronizes binaries and run them
DEVENV_SYNC_BINARIES:
source: env
default: "false"
DEVENV_DEPLOY_IMAGE_SOURCE:
source: env
default: local
DEVENV_DEPLOY_DEV_IMAGE_REGISTRY:
source: env
default: devenv.local
DEVENV_DEPLOY_BOX_IMAGE_REGISTRY:
source: env
default: gcr.io/outreach-docker
DEVENV_DEPLOY_IMAGE_REGISTRY:
source: env
default: ${DEVENV_DEPLOY_BOX_IMAGE_REGISTRY}
DEVENV_TYPE:
source: env
DEVENV_DEV_TERMINAL:
source: env
default: "false"
DEVENV_DEV_SKIP_PORTFORWARDING:
source: env
default: "false"
DEVENV_DEV_ONLY_FORWARD_DELVE:
source: env
default: "false"
DEVENV_DEV_DEPLOYMENT_PROFILE:
source: env
default: deployment__vcluster-fs-syncer
E2E:
source: env
default: "false"
# devenv passes in paths to binaries it uses (ensuring the supported versions are used)
# devenv bin that triggered devspace
# orc setup installs devenv bin so we can fallback to that if needed
DEVENV_BIN:
source: env
default: devenv
# devspace bin for running devspace commands (e.g. devspace run build-jsonnet)
# orc setup installs devspace bin so we can fallback to that if needed
DEVENV_DEVSPACE_BIN:
source: env
default: devspace
# This var isn't produced by devenv, but can be produced by user scripts to override the namespace.
DEVENV_DEPLOY_NAMESPACE:
source: env
default: ${DEVENV_DEPLOY_APPNAME}--bento1a
GH_TOKEN: $([[ "$GH_TOKEN" == "null" ]] && unset GH_TOKEN; gh auth token)
NPM_TOKEN: $(grep -E "registry.npmjs.org(.+)_authToken=(.+)" $HOME/.npmrc | sed 's/.*=//g')
APP_VERSION: $(make version)
BOX_REPOSITORY_URL: $(yq -r '.storageURL' "$HOME/.outreach/.config/box/box.yaml")
DLV_PORT:
source: env
default: 42097
DEV_CONTAINER_WORKDIR: /home/dev/app
DEV_CONTAINER_IMAGE: gcr.io/outreach-docker/bootstrap/dev:stable
DEV_CONTAINER_LOGFILE: /tmp/app.log
DEV_CONTAINER_CACHE: /home/dev/.cache
# `deployments` tells DevSpace how to deploy this project
deployments:
app:
namespace: ${DEVENV_DEPLOY_NAMESPACE}
# This deployment uses `kubectl` but you can also define `helm` deployments
kubectl:
manifests:
- deployments/${DEVENV_DEPLOY_APPNAME}.yaml
# `dev` only applies when you run `devspace dev`
dev:
app:
labelSelector:
app: ${DEVENV_DEPLOY_APPNAME}
namespace: ${DEVENV_DEPLOY_NAMESPACE}
resources:
requests:
cpu: 1
memory: 1Gi
limits:
cpu: 5
memory: 10Gi
# Specifies the dev container to use. In this case gcr.io/outreach-docker/bootstrap/dev:stable
devImage: ${DEV_CONTAINER_IMAGE}
# `dev.app.ports` specifies all ports that should be forwarded while `devspace dev` is running
# Port-forwarding lets you access your application via localhost on your local machine
ports:
- port: 8000
# Remote debugging port
- port: ${DLV_PORT}
# `dev.sync` configures a file sync between our Pods in k8s and your local project files
sync:
# path is localSubPath>:<containerPath>
# https://www.devspace.sh/docs/configuration/dev/connections/file-sync
- path: ./:${DEV_CONTAINER_WORKDIR}
waitInitialSync: true
excludePaths:
- bin
- ./vendor
- node_modules
# Since our Helm charts and manifests deployments are often optimized for production,
# DevSpace let's you swap out Pods dynamically to get a better dev environment
patches:
- op: replace
path: spec.containers[0].command
value:
- bash
- op: replace
path: spec.containers[0].args
value:
- "-c"
- "while ! tail -f ${DEV_CONTAINER_LOGFILE} 2> /dev/null; do sleep 1; done"
- op: replace
path: spec.containers[0].imagePullPolicy
value: Always
- op: remove
path: spec.containers[0].securityContext
- op: remove
path: spec.containers[0].livenessProbe
- op: remove
path: spec.containers[0].readinessProbe
# credentials for package managers
- op: add
path: spec.containers[0].env
value:
name: GH_TOKEN
value: ${GH_TOKEN}
- op: add
path: spec.containers[0].env
value:
name: NPM_TOKEN
value: ${NPM_TOKEN}
# variables for scripts
- op: add
path: spec.containers[0].env
value:
name: DEVENV_DEV_TERMINAL
value: "$!{DEVENV_DEV_TERMINAL}"
- op: add
path: spec.containers[0].env
value:
name: DEV_CONTAINER_LOGFILE
value: ${DEV_CONTAINER_LOGFILE}
- op: add
path: spec.containers[0].env
value:
name: SKIP_DEVCONFIG
value: "true"
- op: add
path: spec.containers[0].env
value:
name: DLV_PORT
value: "$!{DLV_PORT}"
- op: add
path: spec.containers[0].env
value:
name: DEV_CONTAINER_EXECUTABLE
value: ${DEV_CONTAINER_EXECUTABLE}
- op: add
path: spec.containers[0].env
value:
name: BOX_REPOSITORY_URL
value: ${BOX_REPOSITORY_URL}
# Cache for packages, build cache, etc.
- op: add
path: spec.volumes
value:
name: devspace-cache
persistentVolumeClaim:
claimName: devspace-cache
- op: add
path: spec.containers[0].volumeMounts
value:
mountPath: ${DEV_CONTAINER_CACHE}
name: devspace-cache
# asdf install volume, mounted into `installs` and `shims` directories.
- op: add
path: spec.volumes
value:
name: asdf
persistentVolumeClaim:
claimName: devspace-asdfinstall
- op: add
path: spec.containers[0].volumeMounts
value:
mountPath: /home/dev/.asdf/installs
name: asdf
subPath: installs
- op: add
path: spec.containers[0].volumeMounts
value:
mountPath: /home/dev/.asdf/shims
name: asdf
subPath: shims
# Storage for sources - this way we don't have to sync everything every time, makes startup faster
- op: add
path: spec.volumes
value:
name: devspace-appcache
persistentVolumeClaim:
claimName: devspace-appcache
- op: add
path: spec.containers[0].volumeMounts
value:
mountPath: ${DEV_CONTAINER_WORKDIR}
name: devspace-appcache
commands:
# The image tags get replaced by devspace automatically.
build-jsonnet: |-
./scripts/shell-wrapper.sh build-jsonnet.sh show > deployments/${DEVENV_DEPLOY_APPNAME}.yaml
hooks:
- name: render-manifests
command: "${DEVENV_DEVSPACE_BIN} run build-jsonnet"
events: ["before:deploy"]
- name: delete-jobs
command: |-
"$DEVENV_BIN" --skip-update k --namespace "${DEVENV_DEPLOY_NAMESPACE}" delete jobs --all
events: ["before:deploy"]
- name: auth-refresh
command: "${DEVENV_BIN} --skip-update auth refresh"
events: ["before:build"]
profiles:
- name: devTerminal
description: dev command opens a terminal into dev container. Automatically activated based on $DEVENV_DEV_TERMINAL == true var.
activation:
- vars:
DEVENV_DEV_TERMINAL: "true"
DEVENV_SYNC_BINARIES: "false"
patches:
- op: add
path: hooks
value:
name: reset-dev
events: ["devCommand:after:execute"]
command: |-
"${DEVENV_DEVSPACE_BIN}" reset pods -s
merge:
dev:
app:
# https://www.devspace.sh/docs/configuration/dev/#dev-terminal
terminal:
enabled: true
disableReplace: true
workDir: ${DEV_CONTAINER_WORKDIR}
command: |-
./scripts/shell-wrapper.sh devspace_start.sh
- name: devStartService
description: dev command starts service in dev container. Automatically activated based on $DEVENV_DEV_TERMINAL == false var.
activation:
- vars:
DEVENV_DEV_TERMINAL: "false"
DEVENV_SYNC_BINARIES: "false"
patches:
- op: add
path: hooks
value:
name: reset-dev-interrupt
events: ["devCommand:interrupt"]
command: |-
"${DEVENV_DEVSPACE_BIN}" reset pods -s
- op: add
path: hooks
value:
name: reset-dev-error
events: ["error:sync:app"]
command: |-
"${DEVENV_DEVSPACE_BIN}" reset pods -s
- op: add
path: hooks
value:
name: make-dev
events: ["after:initialSync:app"]
command: |-
cd "${DEV_CONTAINER_WORKDIR}"
"${DEV_CONTAINER_WORKDIR}/scripts/shell-wrapper.sh" devspace_start.sh
container:
imageSelector: ${DEV_CONTAINER_IMAGE}
labelSelector:
app: ${DEVENV_DEPLOY_APPNAME}
- name: onlyForwardDlv
description: Skip port-forwarding for all but the Delve port. This is the default behavior.
activation:
- vars:
DEVENV_DEV_ONLY_FORWARD_DELVE: "true"
patches:
- op: replace
path: dev.app.ports
value:
- port: ${DLV_PORT}
- name: skipPortForwarding
description: Skip port-forwarding for all but the DLV port.
activation:
- vars:
DEVENV_DEV_SKIP_PORTFORWARDING: "true"
- name: e2eBase
description: Basic configuration override for all e2e test profiles
activation:
- vars:
E2E: "true"
patches:
- op: add
path: dev.app.patches
value:
op: replace
path: spec.serviceAccountName
value: "vcluster-fs-syncer-e2e-client-svc"
- name: e2e
activation:
- vars:
E2E: "true"
DEVENV_DEV_TERMINAL: "false"
DEVENV_SYNC_BINARIES: "false"
patches:
# For E2E we want to sync files once and stop.
- op: add
path: dev.app.sync[*].noWatch
value: true
- op: add
path: dev.app.patches
value:
op: add
path: spec.containers[0].env
value:
name: E2E
value: "true"
- name: e2eWithTerminal
activation:
- vars:
E2E: "true"
DEVENV_DEV_TERMINAL: "true"
DEVENV_SYNC_BINARIES: "false"
patches:
- op: add
path: dev.app.patches
value:
op: add
path: spec.containers[0].env
value:
name: E2E
value: "true"
- name: binarySyncE2e
description: Additional configuration for binary sync when running e2e tests (devenv apps e2e -b)
activation:
- vars:
E2E: "true"
DEVENV_DEV_TERMINAL: "false"
DEVENV_SYNC_BINARIES: "true"
patches:
- op: add
path: dev.app.patches
value:
op: add
path: spec.containers[0].env
value:
name: E2E
value: "true"
- op: add
path: hooks
value:
name: copy-test-results
events: ["devCommand:after:execute"]
container:
imageSelector: ${DEV_CONTAINER_IMAGE}
download:
containerPath: ${DEV_CONTAINER_WORKDIR}/unit-tests.xml
localPath: ./bin/unit-tests.xml
- name: binarySyncDev
description: Synchronizes just content of bin folder and don't do any build related stuff in the devspace pod (devenv apps run -b)
activation:
- vars:
DEVENV_SYNC_BINARIES: "true"
patches:
- op: replace
path: vars.DEV_CONTAINER_IMAGE
value: gcr.io/outreach-docker/bootstrap/dev-slim:stable
- op: replace
path: dev.app.sync[0]
value:
path: ./bin:${DEV_CONTAINER_WORKDIR}
printLogs: true
disableDownload: true
waitInitialSync: true
- op: add
path: hooks
value:
name: reset-dev
events: ["devCommand:after:execute"]
command: |-
"${DEVENV_DEVSPACE_BIN}" reset pods -s
merge:
dev:
app:
# https://www.devspace.sh/docs/configuration/dev/#dev-terminal
terminal:
enabled: true
disableReplace: true
workDir: ${DEV_CONTAINER_WORKDIR}
command: |-
entrypoint
- name: Loft
description: >
Enables deploying to Loft.
Automatically activated based on $DEVENV_TYPE var.
activation:
- vars:
DEVENV_TYPE: loft
patches:
- op: add
path: dev.app.patches
value:
op: add
path: spec.containers[0].nodeSelector
value:
cloud.google.com/gke-nodepool: devspace
- op: add
path: dev.app.patches
value:
op: add
path: spec.tolerations
value:
- key: "devspace"
operator: "Equal"
value: "true"
effect: "NoSchedule"
- op: add
path: dev.app.patches
value:
op: add
path: spec.securityContext
value:
runAsUser: 1000
fsGroup: 1000
runAsGroup: 1000
- op: add
path: dev.app.patches
value:
op: replace
path: spec.containers[0].resources
value:
limits:
cpu: 4
memory: 12Gi
requests:
cpu: 3 # 4 cores on the VM right now, so we can't request more than that
memory: 12Gi
# App Profiles
# Profiles starting with deployment__ are treated specially by devenv.
# You get to choose from them which app you want to substitute with the dev container.
- name: deployment__vcluster-fs-syncer
description: Default app profile. This doesn't change configuration, because it's set by default.
activation:
- vars:
DEVENV_DEV_DEPLOYMENT_PROFILE: deployment__vcluster-fs-syncer
## <<Stencil::Block(profiles)>>
## <</Stencil::Block>>