-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathTaskfile.test-env.yml
More file actions
569 lines (520 loc) · 27.9 KB
/
Taskfile.test-env.yml
File metadata and controls
569 lines (520 loc) · 27.9 KB
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
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# Copyright AGNTCY Contributors (https://github.com/agntcy)
# SPDX-License-Identifier: Apache-2.0
version: "3"
tasks:
default:
cmd: echo "Run the main Taskfile instead of this one."
test-env:kubernetes:setup-cluster:
desc: Create a kind cluster and load Docker images
deps:
- deps:helm
- deps:kubectl
- deps:kind
vars:
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
KIND_CREATE_OPTS: '{{ .KIND_CREATE_OPTS | default "" }}'
KIND_CLUSTER_CONFIG_PATH:
sh: mktemp
# Port mapping is defined in the format of "hostPort1:containerPort1,hostPort2:containerPort2".
# Container port should match the NodePort of the service defined in the Helm chart.
KIND_EXTRA_PORT_MAPPING: '{{ .KIND_EXTRA_PORT_MAPPING | default "" }}'
E2E_COVERAGE_ENABLED: '{{ .E2E_COVERAGE_ENABLED | default "false" }}'
DEPLOY_BAKE_ENV: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}{{ .COVERAGE_BAKE_ENV }}{{ else }}{{ .BAKE_ENV }}{{ end }}'
DEPLOY_BAKE_GROUP: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}coverage{{ else }}default{{ end }}'
cmds:
# Create cluster config
- |
cat <<EOF > {{.KIND_CLUSTER_CONFIG_PATH}}
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
{{ if .KIND_EXTRA_PORT_MAPPING }}
extraPortMappings:
{{ range .KIND_EXTRA_PORT_MAPPING | splitList "," }}
- hostPort: {{ index (splitList ":" .) 0 }}
containerPort: {{ index (splitList ":" .) 1 }}
listenAddress: "127.0.0.1"
protocol: TCP
{{ end }}
{{ end }}
EOF
# Create cluster
- |
{{ .KIND_BIN }} create cluster {{ .KIND_CREATE_OPTS }} --name {{ .KIND_CLUSTER_NAME }} --config {{ .KIND_CLUSTER_CONFIG_PATH }}
{{ .KIND_BIN }} export kubeconfig --name {{ .KIND_CLUSTER_NAME }}
{{ .KUBECTL_BIN }} cluster-info
# Load images
- |
images=$({{.DEPLOY_BAKE_ENV}} docker buildx bake {{.DEPLOY_BAKE_GROUP}} --print | jq -r '.target | with_entries(.value |= .tags[0]) | to_entries[] | .value')
echo "$images" | while read image; do
{{ .KIND_BIN }} load docker-image $image --name {{ .KIND_CLUSTER_NAME }}
done
test-env:kubernetes:gen-htpasswd-creds:
desc: Generate htpasswd credentials and files for DIR deployment
vars:
HTPASSWD_USERNAME: '{{ .HTPASSWD_USERNAME | default "apiserver" }}'
HTPASSWD_SYNC_USERNAME: '{{ .HTPASSWD_SYNC_USERNAME | default "sync-user" }}'
CREDS_FILE: '{{ .CREDS_FILE | default "/tmp/dir-htpasswd-creds.env" }}'
HTPASSWD_FILE: '{{ .HTPASSWD_FILE | default "/tmp/dir-htpasswd" }}'
cmds:
- |
# Generate fresh passwords
HTPASSWD_PASSWORD="$(openssl rand -hex 16)"
HTPASSWD_SYNC_PASSWORD="$(openssl rand -hex 16)"
# Generate derived values
HTPASSWD_AUTH_HEADER="$(echo -n "{{ .HTPASSWD_USERNAME }}:${HTPASSWD_PASSWORD}" | base64)"
HTPASSWD_ADMIN="$(htpasswd -nbB "{{ .HTPASSWD_USERNAME }}" "${HTPASSWD_PASSWORD}" | sed 's/^{{ .HTPASSWD_USERNAME }}://')"
HTPASSWD_SYNC="$(htpasswd -nbB "{{ .HTPASSWD_SYNC_USERNAME }}" "${HTPASSWD_SYNC_PASSWORD}" | sed 's/^{{ .HTPASSWD_SYNC_USERNAME }}://')"
# Write credentials to env file (for helm --set commands)
cat > {{ .CREDS_FILE }} << EOF
export HTPASSWD_USERNAME="{{ .HTPASSWD_USERNAME }}"
export HTPASSWD_PASSWORD="${HTPASSWD_PASSWORD}"
export HTPASSWD_AUTH_HEADER="${HTPASSWD_AUTH_HEADER}"
export HTPASSWD_SYNC_USERNAME="{{ .HTPASSWD_SYNC_USERNAME }}"
export HTPASSWD_SYNC_PASSWORD="${HTPASSWD_SYNC_PASSWORD}"
EOF
# Write htpasswd file (for helm --set-file commands)
cat > {{ .HTPASSWD_FILE }} << EOF
{{ .HTPASSWD_USERNAME }}:${HTPASSWD_ADMIN}
{{ .HTPASSWD_SYNC_USERNAME }}:${HTPASSWD_SYNC}
EOF
test-env:kubernetes:cleanup-htpasswd-creds:
desc: Cleanup htpasswd credentials and files
vars:
CREDS_FILE: '{{ .CREDS_FILE | default "/tmp/dir-htpasswd-creds.env" }}'
HTPASSWD_FILE: '{{ .HTPASSWD_FILE | default "/tmp/dir-htpasswd" }}'
cmds:
- rm -f {{ .CREDS_FILE }}
- rm -f {{ .HTPASSWD_FILE }}
test-env:kubernetes:local:
aliases: [deploy:local]
desc: Deploy a local Directory server in Kubernetes
deps:
- task: test-env:kubernetes:setup-cluster
vars:
KIND_EXTRA_PORT_MAPPING: "{{.API_HOSTPORT}}:{{.API_NODEPORT}},{{.METRICS_HOSTPORT}}:{{.METRICS_NODEPORT}}"
vars:
# Kind args
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
KIND_CREATE_OPTS: '{{ .KIND_CREATE_OPTS | default "" }}'
# Helm args
HELM_NAMESPACE: '{{ .HELM_NAMESPACE | default "dir-server" }}'
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dir"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dir/values.yaml"
# Coverage config
E2E_COVERAGE_ENABLED: '{{ .E2E_COVERAGE_ENABLED | default "false" }}'
DEPLOY_IMAGE_TAG: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}{{ .COVERAGE_IMAGE_TAG }}{{ else }}{{ .IMAGE_TAG }}{{ end }}'
# API config
API_HOSTPORT: '{{ .API_HOSTPORT | default "8888" }}'
API_NODEPORT: '{{ .API_NODEPORT | default "30088" }}'
METRICS_HOSTPORT: '{{ .METRICS_HOSTPORT | default "9090" }}'
METRICS_NODEPORT: '{{ .METRICS_NODEPORT | default "30090" }}'
cmds:
# TODO: make logic idempotent so that running functional tests does not change previous contexts
# Generate credentials and htpasswd file (using defaults)
- task: test-env:kubernetes:gen-htpasswd-creds
# Cleanup credentials on exit (using defaults)
- defer:
task: test-env:kubernetes:cleanup-htpasswd-creds
# Build helm dependencies
- task: helm:dep:build
# Deploy chart
- |
# Load credentials
source /tmp/dir-htpasswd-creds.env
{{ .HELM_BIN }} upgrade dir \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set apiserver.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
--set apiserver.service.type="NodePort" \
--set apiserver.service.nodePort="{{.API_NODEPORT}}" \
--set apiserver.service.metricsNodePort="{{.METRICS_NODEPORT}}" \
{{ if .DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL }}--set apiserver.config.publication.scheduler_interval="{{ .DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL }}"{{ end }} \
{{ if .DIRECTORY_SERVER_NAMING_TTL }}--set apiserver.config.naming.ttl="{{ .DIRECTORY_SERVER_NAMING_TTL }}"{{ end }} \
--set apiserver.config.routing.refresh_interval="1s" \
--set apiserver.secrets.ociAuth.username="${HTPASSWD_USERNAME}" \
--set apiserver.secrets.ociAuth.password="${HTPASSWD_PASSWORD}" \
--set apiserver.zot.authHeader="${HTPASSWD_AUTH_HEADER}" \
--set-file apiserver.zot.secretFiles.htpasswd="/tmp/dir-htpasswd" \
--set apiserver.secrets.syncAuth.username="${HTPASSWD_SYNC_USERNAME}" \
--set apiserver.secrets.syncAuth.password="${HTPASSWD_SYNC_PASSWORD}" \
{{ if .DIRECTORY_SERVER_RATELIMIT_ENABLED }}--set apiserver.config.ratelimit.enabled="{{ .DIRECTORY_SERVER_RATELIMIT_ENABLED }}"{{ end }} \
{{ if .DIRECTORY_SERVER_RATELIMIT_GLOBAL_RPS }}--set apiserver.config.ratelimit.global_rps="{{ .DIRECTORY_SERVER_RATELIMIT_GLOBAL_RPS }}"{{ end }} \
{{ if .DIRECTORY_SERVER_RATELIMIT_GLOBAL_BURST }}--set apiserver.config.ratelimit.global_burst="{{ .DIRECTORY_SERVER_RATELIMIT_GLOBAL_BURST }}"{{ end }} \
{{ if .DIRECTORY_SERVER_RATELIMIT_PER_CLIENT_RPS }}--set apiserver.config.ratelimit.per_client_rps="{{ .DIRECTORY_SERVER_RATELIMIT_PER_CLIENT_RPS }}"{{ end }} \
{{ if .DIRECTORY_SERVER_RATELIMIT_PER_CLIENT_BURST }}--set apiserver.config.ratelimit.per_client_burst="{{ .DIRECTORY_SERVER_RATELIMIT_PER_CLIENT_BURST }}"{{ end }} \
{{ if eq .E2E_COVERAGE_ENABLED "true" }}--set-json 'apiserver.extraEnv=[{"name":"GOCOVERDIR","value":"/tmp/coverage"}]' --set apiserver.coverageVolume=true{{ end }} \
{{ if .DIRECTORY_SERVER_OASF_API_VALIDATION_SCHEMA_URL }}--set apiserver.config.oasf_api_validation.schema_url="{{ .DIRECTORY_SERVER_OASF_API_VALIDATION_SCHEMA_URL }}"{{ end }} \
--set apiserver.reconciler.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
--set apiserver.reconciler.config.regsync.interval="10s" \
--set apiserver.reconciler.config.indexer.interval="10s" \
--set apiserver.reconciler.config.name.interval="5s" \
--set apiserver.reconciler.config.signature.interval="5s" \
--namespace {{ .HELM_NAMESPACE }} \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
test-env:kubernetes:local:ghcr:
aliases: [deploy:local:ghcr]
desc: Deploy a local Directory server in Kubernetes using GHCR as backend (no Zot)
deps:
- task: test-env:kubernetes:setup-cluster
vars:
KIND_EXTRA_PORT_MAPPING: "{{.API_HOSTPORT}}:{{.API_NODEPORT}},{{.METRICS_HOSTPORT}}:{{.METRICS_NODEPORT}}"
vars:
# Kind args
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
# Helm args
HELM_NAMESPACE: '{{ .HELM_NAMESPACE | default "dir-server-ghcr" }}'
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dir"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dir/values.yaml"
# Coverage config
E2E_COVERAGE_ENABLED: '{{ .E2E_COVERAGE_ENABLED | default "false" }}'
DEPLOY_IMAGE_TAG: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}{{ .COVERAGE_IMAGE_TAG }}{{ else }}{{ .IMAGE_TAG }}{{ end }}'
# API config
API_HOSTPORT: '{{ .API_HOSTPORT | default "8888" }}'
API_NODEPORT: '{{ .API_NODEPORT | default "30088" }}'
METRICS_HOSTPORT: '{{ .METRICS_HOSTPORT | default "9090" }}'
METRICS_NODEPORT: '{{ .METRICS_NODEPORT | default "30090" }}'
cmds:
# Validate required environment variables
- |
if [ -z "${DIRECTORY_SERVER_STORE_OCI_AUTH_CONFIG_USERNAME:-}" ] || [ -z "${DIRECTORY_SERVER_STORE_OCI_AUTH_CONFIG_PASSWORD:-}" ] || [ -z "${DIRECTORY_SERVER_STORE_OCI_REPOSITORY_NAME:-}" ]; then
echo "ERROR: DIRECTORY_SERVER_STORE_OCI_AUTH_CONFIG_USERNAME, DIRECTORY_SERVER_STORE_OCI_AUTH_CONFIG_PASSWORD, and DIRECTORY_SERVER_STORE_OCI_REPOSITORY_NAME must be set for GHCR deployment"
exit 1
fi
if [ -z "${DIRECTORY_SERVER_SYNC_AUTH_CONFIG_USERNAME:-}" ] || [ -z "${DIRECTORY_SERVER_SYNC_AUTH_CONFIG_PASSWORD:-}" ]; then
echo "ERROR: DIRECTORY_SERVER_SYNC_AUTH_CONFIG_USERNAME and DIRECTORY_SERVER_SYNC_AUTH_CONFIG_PASSWORD must be set for GHCR deployment"
echo "These credentials are shared with remote directories that want to sync to your GHCR registry"
exit 1
fi
echo "Using GHCR repository: ${DIRECTORY_SERVER_STORE_OCI_REPOSITORY_NAME}"
echo "Using GHCR username: ${DIRECTORY_SERVER_STORE_OCI_AUTH_CONFIG_USERNAME}"
# Build helm dependencies
- task: helm:dep:build
# Deploy chart with GHCR backend (no Zot)
- |
{{ .HELM_BIN }} upgrade dir \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set apiserver.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
--set apiserver.service.type="NodePort" \
--set apiserver.service.nodePort="{{.API_NODEPORT}}" \
--set apiserver.service.metricsNodePort="{{.METRICS_NODEPORT}}" \
--set apiserver.config.store.oci.type=ghcr \
--set apiserver.config.store.oci.registry_address="${DIRECTORY_SERVER_STORE_OCI_REGISTRY_ADDRESS}" \
--set apiserver.config.store.oci.repository_name="${DIRECTORY_SERVER_STORE_OCI_REPOSITORY_NAME}" \
--set apiserver.config.store.oci.auth_config.username="${DIRECTORY_SERVER_STORE_OCI_AUTH_CONFIG_USERNAME}" \
--set apiserver.config.store.oci.auth_config.password="${DIRECTORY_SERVER_STORE_OCI_AUTH_CONFIG_PASSWORD}" \
--set apiserver.config.store.oci.auth_config.insecure=false \
--set apiserver.zot.enabled=false \
--set apiserver.secrets.ociAuth.username="${DIRECTORY_SERVER_STORE_OCI_AUTH_CONFIG_USERNAME}" \
--set apiserver.secrets.ociAuth.password="${DIRECTORY_SERVER_STORE_OCI_AUTH_CONFIG_PASSWORD}" \
--set apiserver.secrets.syncAuth.username="${DIRECTORY_SERVER_SYNC_AUTH_CONFIG_USERNAME}" \
--set apiserver.secrets.syncAuth.password="${DIRECTORY_SERVER_SYNC_AUTH_CONFIG_PASSWORD}" \
{{ if .DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL }}--set apiserver.config.publication.scheduler_interval="{{ .DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL }}"{{ end }} \
--set apiserver.config.routing.refresh_interval="1s" \
--set apiserver.config.database.postgres.host=dir-postgresql.{{ .HELM_NAMESPACE }}.svc.cluster.local \
--set apiserver.config.database.postgres.port=5432 \
--set apiserver.postgresql.enabled=true \
--set apiserver.postgresql.auth.username=dir \
--set apiserver.postgresql.auth.password=dirpassword \
--set apiserver.postgresql.auth.database=dir \
--set apiserver.reconciler.config.regsync.interval="10s" \
--set apiserver.reconciler.config.indexer.interval="10s" \
--set apiserver.reconciler.config.name.interval="5s" \
--set apiserver.reconciler.config.signature.interval="5s" \
--set apiserver.reconciler.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
--set apiserver.config.oasf_api_validation.disable=true \
--namespace {{ .HELM_NAMESPACE }} \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
test-env:kubernetes:local:ghcr:cleanup:
aliases: [deploy:local:ghcr:cleanup]
desc: Cleanup Kubernetes environment for local GHCR deployment
cmds:
- "{{ .KIND_BIN }} delete cluster --name {{ .KIND_CLUSTER_NAME }}"
deploy:kubernetes:context:
desc: Switch context to given Kubernetes cluster
vars:
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
cmds:
- "{{ .KIND_BIN }} export kubeconfig --name {{ .KIND_CLUSTER_NAME }}"
test-env:kubernetes:dir:
desc: Deploy DIR helm chart
vars:
HELM_NAMESPACE: '{{ .HELM_NAMESPACE | default "dir-server" }}'
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dir"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dir/values.yaml"
HELM_EXTRA_ARGS: '{{ .HELM_EXTRA_ARGS | default "" }}'
cmds:
# Generate credentials and htpasswd file (using defaults)
- task: test-env:kubernetes:gen-htpasswd-creds
# Cleanup credentials on exit (using defaults)
- defer:
task: test-env:kubernetes:cleanup-htpasswd-creds
# Build helm dependencies
- task: helm:dep:build
# Deploy chart
- |
# Load credentials
source /tmp/dir-htpasswd-creds.env
{{ .HELM_BIN }} upgrade --install dir \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set apiserver.image.tag="{{ .IMAGE_TAG }}" \
{{ if .DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL }}--set apiserver.config.publication.scheduler_interval="{{ .DIRECTORY_SERVER_PUBLICATION_SCHEDULER_INTERVAL }}"{{ end }} \
--set apiserver.secrets.ociAuth.username="${HTPASSWD_USERNAME}" \
--set apiserver.secrets.ociAuth.password="${HTPASSWD_PASSWORD}" \
--set apiserver.zot.authHeader="${HTPASSWD_AUTH_HEADER}" \
--set-file apiserver.zot.secretFiles.htpasswd="/tmp/dir-htpasswd" \
--set apiserver.secrets.syncAuth.username="${HTPASSWD_SYNC_USERNAME}" \
--set apiserver.secrets.syncAuth.password="${HTPASSWD_SYNC_PASSWORD}" \
--set apiserver.log_level="DEBUG" \
--set apiserver.reconciler.image.tag="{{ .IMAGE_TAG }}" \
--set apiserver.reconciler.config.regsync.interval="10s" \
--set apiserver.reconciler.config.indexer.interval="10s" \
--set apiserver.reconciler.config.name.interval="5s" \
--set apiserver.reconciler.config.signature.interval="5s" \
{{ .HELM_EXTRA_ARGS }} \
--namespace {{ .HELM_NAMESPACE }} \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
test-env:kubernetes:dirctl:
desc: Deploy DIRCTL helm chart
vars:
HELM_NAMESPACE: '{{ .HELM_NAMESPACE | default "dir-client" }}'
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dirctl"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dirctl/values.yaml"
HELM_EXTRA_ARGS: '{{ .HELM_EXTRA_ARGS | default "" }}'
cmds:
- |
{{ .HELM_BIN }} upgrade --install dirctl \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set image.tag="{{ .IMAGE_TAG }}" \
{{ .HELM_EXTRA_ARGS }} \
--namespace {{ .HELM_NAMESPACE }} \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
test-env:kubernetes:spire:
desc: Deploy SPIRE helm chart
vars:
TRUST_DOMAIN: '{{ .TRUST_DOMAIN | default "example.org" }}'
SERVICE_TYPE: '{{ .SERVICE_TYPE | default "LoadBalancer" }}'
BUNDLE_PATH: '{{ .BUNDLE_PATH | default "/tmp/spire-bundle.spiffe" }}'
cmds:
- |
{{ .HELM_BIN }} upgrade --install spire-crds spire-crds \
--repo https://spiffe.github.io/helm-charts-hardened/ \
--namespace spire-crds \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
- |
{{ .HELM_BIN }} upgrade --install spire spire \
--repo https://spiffe.github.io/helm-charts-hardened/ \
--set global.spire.trustDomain="{{ .TRUST_DOMAIN }}" \
--set spire-server.image.tag="{{ .SPIRE_VERSION }}" \
--set spire-agent.image.tag="{{ .SPIRE_VERSION }}" \
--set spire-server.service.type="{{ .SERVICE_TYPE }}" \
--set spire-server.federation.enabled="true" \
--set spire-server.controllerManager.watchClassless="true" \
--set spire-server.controllerManager.className="dir-spire" \
--namespace spire \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
- |
{{ .KUBECTL_BIN }} get configmap -n spire spire-bundle -o json | jq '.data."bundle.spiffe"' -r > {{ .BUNDLE_PATH }}
test-env:kubernetes:local:cleanup:
aliases: [deploy:local:cleanup, deploy:kubernetes:cleanup]
desc: Cleanup Kubernetes environment for local deployment
deps:
- deps:kind
vars:
# Kind args
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
cmds:
- "{{ .KIND_BIN }} delete cluster --name {{ .KIND_CLUSTER_NAME }}"
test-env:kubernetes:network:bootstrap:
internal: true
desc: Deploy a bootstrap Directory server in Kubernetes
deps:
- task: test-env:kubernetes:setup-cluster
vars:
E2E_COVERAGE_ENABLED: "{{ .E2E_COVERAGE_ENABLED }}"
KIND_EXTRA_PORT_MAPPING: "{{ .KIND_EXTRA_PORT_MAPPING }}"
- deps:dirctl
vars:
# Helm args
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dir"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dir/values.yaml"
# Coverage config
E2E_COVERAGE_ENABLED: '{{ .E2E_COVERAGE_ENABLED | default "false" }}'
DEPLOY_IMAGE_TAG: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}{{ .COVERAGE_IMAGE_TAG }}{{ else }}{{ .IMAGE_TAG }}{{ end }}'
# API config
KIND_EXTRA_PORT_MAPPING: '{{ .KIND_EXTRA_PORT_MAPPING | default "" }}'
cmds:
# Generate private key if it doesn't exist
- |
test -f /tmp/node.privkey || {{ .BIN_DIR }}/dirctl network init --output /tmp/node.privkey
# Generate the bootstrap peer ID and export it to the environment file
- |
bootstrap_peerid=$({{ .BIN_DIR }}/dirctl network info /tmp/node.privkey)
echo "PEER ID: ${bootstrap_peerid}"
echo BOOTSTRAP_PEER_ID="${bootstrap_peerid}" > .env
# Generate credentials and htpasswd file
- task: test-env:kubernetes:gen-htpasswd-creds
vars:
CREDS_FILE: "/tmp/dir-htpasswd-creds-bootstrap.env"
HTPASSWD_FILE: "/tmp/zot-htpasswd-bootstrap"
# Cleanup credentials on exit
- defer:
task: test-env:kubernetes:cleanup-htpasswd-creds
vars:
CREDS_FILE: "/tmp/dir-htpasswd-creds-bootstrap.env"
HTPASSWD_FILE: "/tmp/zot-htpasswd-bootstrap"
# Build helm dependencies
- task: helm:dep:build
# Deploy the bootstrap server using Helm
- |
# Load credentials
source /tmp/dir-htpasswd-creds-bootstrap.env
{{ .HELM_BIN }} upgrade agntcy-dir \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set apiserver.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
{{ if .PUBLICATION_SCHEDULER_INTERVAL }}--set apiserver.config.publication.scheduler_interval="{{ .PUBLICATION_SCHEDULER_INTERVAL }}"{{ end }} \
--set apiserver.config.routing.refresh_interval="1s" \
--set apiserver.secrets.privKey="$(cat /tmp/node.privkey)" \
--set apiserver.config.routing.key_path="/etc/agntcy/dir/node.privkey" \
--set apiserver.config.routing.listen_address="/ip4/0.0.0.0/tcp/8999" \
--set apiserver.config.routing.directory_api_address="agntcy-dir-apiserver.bootstrap.svc.cluster.local:8888" \
--set apiserver.config.store.oci.registry_address="agntcy-dir-zot.bootstrap.svc.cluster.local:5000" \
--set apiserver.secrets.ociAuth.username="${HTPASSWD_USERNAME}" \
--set apiserver.secrets.ociAuth.password="${HTPASSWD_PASSWORD}" \
--set apiserver.zot.authHeader="${HTPASSWD_AUTH_HEADER}" \
--set-file apiserver.zot.secretFiles.htpasswd="/tmp/zot-htpasswd-bootstrap" \
--set apiserver.secrets.syncAuth.username="${HTPASSWD_SYNC_USERNAME}" \
--set apiserver.secrets.syncAuth.password="${HTPASSWD_SYNC_PASSWORD}" \
{{ if eq .E2E_COVERAGE_ENABLED "true" }}--set-json 'apiserver.extraEnv=[{"name":"GOCOVERDIR","value":"/tmp/coverage"}]' --set apiserver.coverageVolume=true{{ end }} \
--set apiserver.config.oasf_api_validation.schema_url="https://schema.oasf.outshift.com" \
--set apiserver.reconciler.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
--set apiserver.reconciler.config.regsync.interval="10s" \
--set apiserver.reconciler.config.indexer.interval="10s" \
--set apiserver.reconciler.config.name.interval="5s" \
--set apiserver.reconciler.config.signature.interval="5s" \
--namespace "bootstrap" \
--create-namespace \
--install \
--wait \
--wait-for-jobs \
--timeout "15m"
test-env:kubernetes:network:
aliases: [deploy:network]
desc: Deploy a network of Directory servers in Kubernetes (1 bootstrap + 3 peers)
vars:
HELM_CHART_PATH: "{{ .ROOT_DIR }}/install/charts/dir"
HELM_VALUES_PATH: "{{ .ROOT_DIR }}/install/charts/dir/values.yaml"
# Coverage config
E2E_COVERAGE_ENABLED: '{{ .E2E_COVERAGE_ENABLED | default "false" }}'
DEPLOY_IMAGE_TAG: '{{ if eq .E2E_COVERAGE_ENABLED "true" }}{{ .COVERAGE_IMAGE_TAG }}{{ else }}{{ .IMAGE_TAG }}{{ end }}'
# Peers config
KIND_EXTRA_PORT_MAPPING: '8890:30090,8891:30091,8892:30092'
PEERS_MAP:
map:
peer1:
apiNodePort: "30090"
metricsNodePort: "31090"
peer2:
apiNodePort: "30091"
metricsNodePort: "31091"
peer3:
apiNodePort: "30092"
metricsNodePort: "31092"
cmds:
# Build helm dependencies once (shared across deployments)
- task: helm:dep:build
# Deploy bootstrap with explicit var passing (not as dependency)
- task: test-env:kubernetes:network:bootstrap
vars:
PUBLICATION_SCHEDULER_INTERVAL: "{{ .PUBLICATION_SCHEDULER_INTERVAL }}"
E2E_COVERAGE_ENABLED: "{{ .E2E_COVERAGE_ENABLED }}"
KIND_EXTRA_PORT_MAPPING: "{{ .KIND_EXTRA_PORT_MAPPING }}"
# Step 1: Deploy all peer servers without waiting (fast)
- for:
var: PEERS_MAP
cmd: |
export $(cat .env)
# Generate fresh credentials for this peer
task test-env:kubernetes:gen-htpasswd-creds \
CREDS_FILE=/tmp/dir-htpasswd-creds-{{ .KEY }}.env \
HTPASSWD_FILE=/tmp/zot-htpasswd-{{ .KEY }}
# Load credentials
source /tmp/dir-htpasswd-creds-{{ .KEY }}.env
{{ .HELM_BIN }} upgrade agntcy-dir \
{{ .HELM_CHART_PATH }} \
-f {{ .HELM_VALUES_PATH }} \
--set apiserver.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
--set apiserver.service.type="NodePort" \
--set apiserver.service.nodePort="{{ .ITEM.apiNodePort }}" \
--set apiserver.service.metricsNodePort="{{ .ITEM.metricsNodePort }}" \
{{ if .PUBLICATION_SCHEDULER_INTERVAL }}--set apiserver.config.publication.scheduler_interval="{{ .PUBLICATION_SCHEDULER_INTERVAL }}"{{ end }} \
--set apiserver.config.routing.refresh_interval="1s" \
--set apiserver.config.store.oci.registry_address="agntcy-dir-zot.{{ .KEY }}.svc.cluster.local:5000" \
--set apiserver.config.routing.bootstrap_peers[0]="/dns4/agntcy-dir-apiserver-routing.bootstrap.svc.cluster.local/tcp/8999/p2p/${BOOTSTRAP_PEER_ID}" \
--set apiserver.config.routing.directory_api_address="agntcy-dir-apiserver.{{ .KEY }}.svc.cluster.local:8888" \
--set apiserver.secrets.ociAuth.username="${HTPASSWD_USERNAME}" \
--set apiserver.secrets.ociAuth.password="${HTPASSWD_PASSWORD}" \
--set apiserver.zot.authHeader="${HTPASSWD_AUTH_HEADER}" \
--set-file apiserver.zot.secretFiles.htpasswd="/tmp/zot-htpasswd-{{ .KEY }}" \
--set apiserver.secrets.syncAuth.username="${HTPASSWD_SYNC_USERNAME}" \
--set apiserver.secrets.syncAuth.password="${HTPASSWD_SYNC_PASSWORD}" \
{{ if eq .E2E_COVERAGE_ENABLED "true" }}--set-json 'apiserver.extraEnv=[{"name":"GOCOVERDIR","value":"/tmp/coverage"}]' --set apiserver.coverageVolume=true{{ end }} \
--set apiserver.config.oasf_api_validation.schema_url="https://schema.oasf.outshift.com" \
--set apiserver.reconciler.image.tag="{{ .DEPLOY_IMAGE_TAG }}" \
--set apiserver.reconciler.config.regsync.interval="10s" \
--set apiserver.reconciler.config.indexer.interval="10s" \
--set apiserver.reconciler.config.name.interval="5s" \
--set apiserver.reconciler.config.signature.interval="5s" \
--namespace "{{ .KEY }}" \
--create-namespace \
--install
# Cleanup temp files
rm -f /tmp/zot-htpasswd-{{ .KEY }}
rm -f /tmp/dir-htpasswd-creds-{{ .KEY }}.env
# Step 2: Wait for all peer deployments to be ready
- for:
var: PEERS_MAP
cmd: |
echo "Waiting for {{ .KEY }} deployments to be ready..."
{{ .KUBECTL_BIN }} wait --for=condition=available deployment/agntcy-dir-apiserver -n {{ .KEY }} --timeout=15m
{{ .KUBECTL_BIN }} wait --for=condition=available deployment/agntcy-dir-reconciler -n {{ .KEY }} --timeout=15m
{{ .KUBECTL_BIN }} wait --for=condition=ready pod -l app.kubernetes.io/name=zot -n {{ .KEY }} --timeout=15m
{{ .KUBECTL_BIN }} wait --for=condition=ready pod -l app.kubernetes.io/name=postgresql -n {{ .KEY }} --timeout=15m
echo "{{ .KEY }} is ready"
test-env:kubernetes:network:cleanup:
aliases: [deploy:network:cleanup]
desc: Cleanup Kubernetes environment for network deployment
vars:
# Kind args
KIND_CLUSTER_NAME: '{{ .KIND_CLUSTER_NAME | default "agntcy-cluster" }}'
cmds:
- "{{ .KIND_BIN }} delete cluster --name {{ .KIND_CLUSTER_NAME }}"