Skip to content

Commit f07f8d0

Browse files
committed
feat(helm): add init container configuration hooks
1 parent 3ad607e commit f07f8d0

9 files changed

Lines changed: 138 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ The TypeScript sources live in `src/`. CLI flows under `src/cli/` orchestrate pr
88

99
Install dependencies with `bun install`. Use `bun run src/index.ts` to execute the bootstrapper locally. Run the full test suite with `bun test`. Type safety is enforced by `bun run typecheck`, and formatting plus lint rules are auto-fixed with `bun run check:fix` (Biome). Combine these commands before pushing to catch regressions early.
1010

11+
## Documentation
12+
13+
Regenerate Helm chart documentation with `helm-docs` (`bun run docs:helm`) after modifying any values or templates so every README stays in helm-docs format. When editing `values.yaml`, ensure each key has a helm-docs compatible comment block (`# -- description`) including type hints or context so autogenerated tables stay complete.
14+
1115
## Coding Style & Naming Conventions
1216

1317
We write modern ESM TypeScript with strict compiler options. Keep indentation at two spaces and favor `const` over `let`. Module files follow kebab-case (for example, `build-command.ts`), functions and variables use camelCase, and classes use PascalCase. Rely on Biome defaults; do not disable rules unless you add justification. Avoid `console` noise in committed code—prefer structured logging through existing helpers.

charts/network/charts/network-bootstrapper/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ A Helm chart for Kubernetes
2020
| image.repository | string | `"ghcr.io/settlemint/network-bootstrapper"` | OCI registry path hosting the network bootstrapper image. |
2121
| image.tag | string | `""` | Image tag override; leave empty to inherit the chart appVersion. |
2222
| imagePullSecrets | list | `[]` | Image pull secrets enabling access to private registries. |
23+
| initContainers | list|string | `[]` | Init containers executed before the bootstrapper container starts. |
2324
| nameOverride | string | `""` | Override for the short release name used by name templates. |
2425
| nodeSelector | object | `{}` | |
2526
| podAnnotations | object | `{}` | |

charts/network/charts/network-bootstrapper/templates/job.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ spec:
2929
securityContext:
3030
{{- toYaml . | nindent 8 }}
3131
{{- end }}
32+
{{- with .Values.initContainers }}
33+
initContainers:
34+
{{- if kindIs "string" . -}}
35+
{{ tpl . $ | nindent 8 }}
36+
{{- else -}}
37+
{{ tpl (toYaml .) $ | nindent 8 }}
38+
{{- end }}
39+
{{- end }}
3240
containers:
3341
- name: {{ .Chart.Name }}
3442
{{- with .Values.securityContext }}

charts/network/charts/network-bootstrapper/values.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,37 @@ securityContext:
5353
# runAsNonRoot: true
5454
# runAsUser: 1000
5555

56+
# -- (list|string) Init containers executed before the bootstrapper container starts.
57+
initContainers: []
58+
# - name: wait-for-genesis
59+
# image: busybox:1.36
60+
# imagePullPolicy: IfNotPresent
61+
# command:
62+
# - sh
63+
# - -c
64+
# args:
65+
# - >-
66+
# until nc -z ${STATIC_NODE_HOST:?} ${STATIC_NODE_PORT:?}; do echo "waiting for nodes"; sleep 2; done
67+
# env:
68+
# - name: STATIC_NODE_HOST
69+
# value: besu-node-validator-0.besu-node-validator
70+
# - name: STATIC_NODE_PORT
71+
# value: "30303"
72+
# envFrom:
73+
# - secretRef:
74+
# name: bootstrapper-env
75+
# volumeMounts:
76+
# - name: config
77+
# mountPath: /config
78+
# resources:
79+
# requests:
80+
# cpu: 50m
81+
# memory: 64Mi
82+
# securityContext: {}
83+
# workingDir: /config
84+
# stdin: false
85+
# tty: false
86+
5687
# CPU and memory requests or limits for the bootstrapper container.
5788
resources:
5889
{}

charts/network/charts/network-nodes/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ A Helm chart for Kubernetes
7777
| ingress.enabled | bool | `false` | Enable creation of an Ingress resource. |
7878
| ingress.hosts | list | `[{"host":"chart-example.local","paths":[{"path":"/","pathType":"ImplementationSpecific"}]}]` | Hostname and path routing rules for the Ingress. |
7979
| ingress.tls | list | `[]` | TLS configuration for Ingress hosts. |
80+
| initContainers.rpc | list|string | `[]` | Additional init containers exclusively for RPC pods. |
81+
| initContainers.shared | list|string | `[]` | Init containers applied to both validator and RPC pods. |
82+
| initContainers.validator | list|string | `[]` | Additional init containers exclusively for validator pods. |
8083
| livenessProbe.failureThreshold | int | `3` | Consecutive failures required before the container is restarted. |
8184
| livenessProbe.httpGet.path | string | `"/liveness"` | HTTP path used for liveness probing. |
8285
| livenessProbe.httpGet.port | string|int | `"json-rpc"` | Target container port serving the liveness endpoint. |

charts/network/charts/network-nodes/templates/_helpers.tpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,20 @@ Create the name of the service account to use
6060
{{- default "default" .Values.serviceAccount.name }}
6161
{{- end }}
6262
{{- end }}
63+
64+
{{/*
65+
Render init container specifications provided via values.
66+
Accepts either a YAML string or a list of init container maps and indents output appropriately.
67+
*/}}
68+
{{- define "nodes.renderInitContainers" -}}
69+
{{- $ctx := .context -}}
70+
{{- $containers := .containers -}}
71+
{{- $indent := .indent | default 2 -}}
72+
{{- if $containers }}
73+
{{- if kindIs "string" $containers -}}
74+
{{ tpl $containers $ctx | nindent $indent }}
75+
{{- else -}}
76+
{{ tpl (toYaml $containers) $ctx | nindent $indent }}
77+
{{- end -}}
78+
{{- end -}}
79+
{{- end }}

charts/network/charts/network-nodes/templates/statefulset-rpc.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ spec:
2828
{{- $privateKeyFilename := default "privateKey" .Values.config.privateKeyFilename }}
2929
{{- $shouldMountPersistence := $persistenceEnabled }}
3030
{{- $rpcReplicaBudget := .Values.rpcReplicaCount | int }}
31+
{{- $initContainers := .Values.initContainers | default (dict) }}
32+
{{- $sharedInitContainers := get $initContainers "shared" }}
33+
{{- $rpcInitContainers := get $initContainers "rpc" }}
3134
podManagementPolicy: Parallel
3235
replicas: {{ .Values.rpcReplicaCount }}
3336
serviceName: {{ include "nodes.fullname" . }}-rpc
@@ -66,6 +69,11 @@ spec:
6669
securityContext:
6770
{{- toYaml . | nindent 8 }}
6871
{{- end }}
72+
{{- if or $sharedInitContainers $rpcInitContainers }}
73+
initContainers:
74+
{{- include "nodes.renderInitContainers" (dict "context" $root "containers" $sharedInitContainers "indent" 8) }}
75+
{{- include "nodes.renderInitContainers" (dict "context" $root "containers" $rpcInitContainers "indent" 8) }}
76+
{{- end }}
6977
containers:
7078
- name: {{ .Chart.Name }}
7179
env:

charts/network/charts/network-nodes/templates/statefulset-validator.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ spec:
2828
{{- $privateKeyFilename := default "privateKey" .Values.config.privateKeyFilename }}
2929
{{- $shouldMountPersistence := $persistenceEnabled }}
3030
{{- $validatorReplicaBudget := .Values.validatorReplicaCount | int }}
31+
{{- $initContainers := .Values.initContainers | default (dict) }}
32+
{{- $sharedInitContainers := get $initContainers "shared" }}
33+
{{- $validatorInitContainers := get $initContainers "validator" }}
3134
replicas: {{ .Values.validatorReplicaCount }}
3235
serviceName: {{ include "nodes.fullname" . }}
3336
{{- if and $useClaimTemplate (or (ne $whenDeleted "") (ne $whenScaled "")) }}
@@ -65,6 +68,11 @@ spec:
6568
securityContext:
6669
{{- toYaml . | nindent 8 }}
6770
{{- end }}
71+
{{- if or $sharedInitContainers $validatorInitContainers }}
72+
initContainers:
73+
{{- include "nodes.renderInitContainers" (dict "context" $root "containers" $sharedInitContainers "indent" 8) }}
74+
{{- include "nodes.renderInitContainers" (dict "context" $root "containers" $validatorInitContainers "indent" 8) }}
75+
{{- end }}
6876
containers:
6977
- name: {{ .Chart.Name }}
7078
env:

charts/network/charts/network-nodes/values.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,64 @@ volumeMounts: []
408408
# mountPath: "/etc/foo"
409409
# readOnly: true
410410

411+
# Init containers executed before Besu containers start.
412+
initContainers:
413+
# -- (list|string) Init containers applied to both validator and RPC pods.
414+
shared: []
415+
# - name: install-plugins
416+
# image: busybox:1.36
417+
# command:
418+
# - sh
419+
# - -c
420+
# args:
421+
# - >-
422+
# cp /extensions/*.jar /data/plugins && chmod 644 /data/plugins/*.jar
423+
# env:
424+
# - name: BESU_LOG
425+
# value: DEBUG
426+
# envFrom:
427+
# - configMapRef:
428+
# name: besu-env
429+
# volumeMounts:
430+
# - name: data
431+
# mountPath: /data
432+
# resources:
433+
# requests:
434+
# cpu: 75m
435+
# memory: 128Mi
436+
# securityContext:
437+
# runAsNonRoot: true
438+
# workingDir: /work
439+
# stdin: false
440+
# tty: false
441+
# -- (list|string) Additional init containers exclusively for validator pods.
442+
validator: []
443+
# - name: wait-for-bootstrapper
444+
# image: busybox:1.36
445+
# command:
446+
# - sh
447+
# - -c
448+
# args:
449+
# - >-
450+
# until nslookup bootstrapper.{{ .Release.Namespace }}.svc.cluster.local; do echo "waiting"; sleep 3; done
451+
# resources:
452+
# limits:
453+
# cpu: 25m
454+
# memory: 32Mi
455+
# -- (list|string) Additional init containers exclusively for RPC pods.
456+
rpc: []
457+
# - name: warm-cache
458+
# image: curlimages/curl:8.10.1
459+
# command:
460+
# - sh
461+
# - -c
462+
# args:
463+
# - curl -sf http://metadata/config && echo "cache primed"
464+
# resources:
465+
# requests:
466+
# cpu: 25m
467+
# memory: 32Mi
468+
411469
# Node selector constraints influencing where Besu pods can schedule.
412470
nodeSelector: {}
413471

0 commit comments

Comments
 (0)