Skip to content

Commit a50f165

Browse files
authored
feat: add configurable init containers (#11)
## Summary - allow bootstrapper and node pods to define init containers through values with tpl support - expand values annotations and helm-docs output to cover new keys - document helm-docs expectations in AGENTS.md ## Testing - bun run typecheck - bun run check - bun run test - bun run check:fix - bun run docs:helm ## Summary by Sourcery Add support for configurable init containers in the network-bootstrapper and network-nodes Helm charts, including templating for shared, validator, and RPC pods, and update documentation accordingly. New Features: - Allow defining initContainers via chart values for both bootstrapper and node pods, with separate shared, validator, and RPC configurations and tpl support Enhancements: - Introduce a helper template to render initContainers in statefulsets and jobs - Update Helm chart values and README files to include initContainers keys for bootstrapper, validator, and RPC pods Documentation: - Extend AGENTS.md with instructions for regenerating Helm chart documentation using helm-docs - Add initContainers sections to network-bootstrapper and network-nodes README files
1 parent 18b31b3 commit a50f165

12 files changed

Lines changed: 155 additions & 4 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/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: network-bootstrapper
33
description: A Helm chart for Kubernetes
44
type: application
5-
version: 0.1.0
5+
version: 0.1.1
66
appVersion: "0.1.0"
77
maintainers:
88
- name: SettleMint

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# network-bootstrapper
22

3-
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
3+
![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
44

55
A Helm chart for Kubernetes
66

@@ -27,6 +27,7 @@ A Helm chart for Kubernetes
2727
| image.repository | string | `"ghcr.io/settlemint/network-bootstrapper"` | OCI registry path hosting the network bootstrapper image. |
2828
| image.tag | string | `""` | Image tag override; leave empty to inherit the chart appVersion. |
2929
| imagePullSecrets | list | `[]` | Image pull secrets enabling access to private registries. |
30+
| initContainers | list|string | `[]` | Init containers executed before the bootstrapper container starts. |
3031
| nameOverride | string | `""` | Override for the short release name used by name templates. |
3132
| nodeSelector | object | `{}` | |
3233
| podAnnotations | object | `{}` | |

charts/network/charts/network-bootstrapper/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 "network-bootstrapper.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-bootstrapper/templates/job.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ spec:
3131
securityContext:
3232
{{- toYaml . | nindent 8 }}
3333
{{- end }}
34+
{{- with .Values.initContainers }}
35+
initContainers:
36+
{{- include "network-bootstrapper.renderInitContainers" (dict "context" $ "containers" . "indent" 8) }}
37+
{{- end }}
3438
containers:
3539
- name: {{ .Chart.Name }}
3640
{{- 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/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: network-nodes
33
description: A Helm chart for Kubernetes
44
type: application
5-
version: 0.1.0
5+
version: 0.1.1
66
appVersion: "0.1.0"
77
maintainers:
88
- name: SettleMint

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# network-nodes
22

3-
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
3+
![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
44

55
A Helm chart for Kubernetes
66

@@ -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
@@ -86,3 +86,20 @@ Resolve the number of validator replicas, falling back to global overrides when
8686
{{- end -}}
8787
{{- end -}}
8888
{{- end }}
89+
90+
{{/*
91+
Render init container specifications provided via values.
92+
Accepts either a YAML string or a list of init container maps and indents output appropriately.
93+
*/}}
94+
{{- define "nodes.renderInitContainers" -}}
95+
{{- $ctx := .context -}}
96+
{{- $containers := .containers -}}
97+
{{- $indent := .indent | default 2 -}}
98+
{{- if $containers -}}
99+
{{- if kindIs "string" $containers -}}
100+
{{ tpl $containers $ctx | nindent $indent }}
101+
{{- else -}}
102+
{{ tpl (toYaml $containers) $ctx | nindent $indent }}
103+
{{- end -}}
104+
{{- end -}}
105+
{{- 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:

0 commit comments

Comments
 (0)