Skip to content

Commit d59eb99

Browse files
committed
feat(helm): support external artifact sourcing
1 parent 3ad607e commit d59eb99

8 files changed

Lines changed: 183 additions & 5 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ A Helm chart for Kubernetes
1515
| Key | Type | Default | Description |
1616
|-----|------|---------|-------------|
1717
| affinity | object | `{}` | |
18+
| artifacts.external.faucet.address | string | `""` | Faucet account address stored in the `besu-faucet-address` ConfigMap when `source` equals `external`. |
19+
| artifacts.external.faucet.privateKey | string | `""` | Faucet private key stored in the `besu-faucet-private-key` Secret when `source` equals `external`. |
20+
| artifacts.external.faucet.publicKey | string | `""` | Faucet account public key stored in the `besu-faucet-pubkey` ConfigMap when `source` equals `external`. |
21+
| artifacts.external.genesis | object | `{}` | Besu genesis document rendered into the `besu-genesis` ConfigMap when `source` equals `external`. |
22+
| artifacts.external.staticNodes | list | `[]` | Collection of enode URIs persisted to the `besu-static-nodes` ConfigMap when `source` equals `external`. |
23+
| artifacts.external.validators | list | `[]` | Validator node definitions providing the data expected by the nodes chart. Each entry must include `address`, `publicKey`, `privateKey`, and `enode`. |
24+
| artifacts.source | string | `"generated"` | Determines how Besu network artifacts are populated. Use `generated` to run the job or `external` to supply values manually. |
1825
| fullnameOverride | string | `"bootstrapper"` | Override for the fully qualified resource name generated by helpers. |
1926
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy controlling when Kubernetes fetches updated image layers. |
2027
| image.repository | string | `"ghcr.io/settlemint/network-bootstrapper"` | OCI registry path hosting the network bootstrapper image. |
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{{- $artifactSource := default "generated" .Values.artifacts.source -}}
2+
{{- if eq $artifactSource "external" }}
3+
{{- $root := . -}}
4+
{{- $external := .Values.artifacts.external | default (dict) -}}
5+
{{- $genesis := get $external "genesis" -}}
6+
{{- $staticNodes := get $external "staticNodes" -}}
7+
{{- $validators := get $external "validators" -}}
8+
{{- $faucet := get $external "faucet" -}}
9+
{{- $validatorCount := len $validators -}}
10+
{{- if not $genesis }}{{ fail "artifacts.external.genesis must be provided when artifacts.source is 'external'." }}{{- end }}
11+
{{- if not $staticNodes }}{{ fail "artifacts.external.staticNodes must include at least one enode when artifacts.source is 'external'." }}{{- end }}
12+
{{- if not $validators }}{{ fail "artifacts.external.validators must include at least one entry when artifacts.source is 'external'." }}{{- end }}
13+
{{- if not ($faucet.address) }}{{ fail "artifacts.external.faucet.address must be set when artifacts.source is 'external'." }}{{- end }}
14+
{{- if not ($faucet.publicKey) }}{{ fail "artifacts.external.faucet.publicKey must be set when artifacts.source is 'external'." }}{{- end }}
15+
{{- if not ($faucet.privateKey) }}{{ fail "artifacts.external.faucet.privateKey must be set when artifacts.source is 'external'." }}{{- end }}
16+
{{- $globalValues := default (dict) .Values.global -}}
17+
{{- $globalReplicaCount := -1 -}}
18+
{{- if and (kindIs "map" $globalValues) (hasKey $globalValues "network") -}}
19+
{{- $networkGlobal := index $globalValues "network" -}}
20+
{{- if and (kindIs "map" $networkGlobal) (hasKey $networkGlobal "validatorReplicaCount") -}}
21+
{{- $globalReplicaCount = (index $networkGlobal "validatorReplicaCount" | int) -}}
22+
{{- end -}}
23+
{{- end -}}
24+
{{- if and (eq $globalReplicaCount -1) (kindIs "map" $globalValues) (hasKey $globalValues "validatorReplicaCount") -}}
25+
{{- $globalReplicaCount = (index $globalValues "validatorReplicaCount" | int) -}}
26+
{{- end -}}
27+
{{- if eq $globalReplicaCount -1 -}}
28+
{{- fail (printf "artifacts.external.validators has %d entries. Set global.validatorReplicaCount (or global.network.validatorReplicaCount) to this value and align network-nodes.validatorReplicaCount." $validatorCount) -}}
29+
{{- end -}}
30+
{{- if ne $globalReplicaCount $validatorCount -}}
31+
{{- fail (printf "artifacts.external.validators has %d entries but the configured validator replica count is %d. Update global.validatorReplicaCount (or global.network.validatorReplicaCount) and network-nodes.validatorReplicaCount to match." $validatorCount $globalReplicaCount) -}}
32+
{{- end -}}
33+
apiVersion: v1
34+
kind: ConfigMap
35+
metadata:
36+
name: besu-genesis
37+
labels:
38+
{{- include "network-bootstrapper.labels" . | nindent 4 }}
39+
data:
40+
genesis.json: |-
41+
{{ toPrettyJson $genesis | indent 4 }}
42+
---
43+
apiVersion: v1
44+
kind: ConfigMap
45+
metadata:
46+
name: besu-static-nodes
47+
labels:
48+
{{- include "network-bootstrapper.labels" . | nindent 4 }}
49+
data:
50+
static-nodes.json: |-
51+
{{ toPrettyJson $staticNodes | indent 4 }}
52+
{{- range $index, $validator := $validators }}
53+
{{- $requiredAddress := required (printf "artifacts.external.validators[%d].address must be set." $index) $validator.address }}
54+
{{- $requiredPublicKey := required (printf "artifacts.external.validators[%d].publicKey must be set." $index) $validator.publicKey }}
55+
{{- $requiredPrivateKey := required (printf "artifacts.external.validators[%d].privateKey must be set." $index) $validator.privateKey }}
56+
{{- $requiredEnode := required (printf "artifacts.external.validators[%d].enode must be set." $index) $validator.enode }}
57+
---
58+
apiVersion: v1
59+
kind: ConfigMap
60+
metadata:
61+
name: {{ printf "besu-node-validator-%d-address" $index }}
62+
labels:
63+
{{- include "network-bootstrapper.labels" $root | nindent 4 }}
64+
data:
65+
address: {{ $requiredAddress | quote }}
66+
---
67+
apiVersion: v1
68+
kind: ConfigMap
69+
metadata:
70+
name: {{ printf "besu-node-validator-%d-enode" $index }}
71+
labels:
72+
{{- include "network-bootstrapper.labels" $root | nindent 4 }}
73+
data:
74+
enode: {{ $requiredEnode | quote }}
75+
---
76+
apiVersion: v1
77+
kind: ConfigMap
78+
metadata:
79+
name: {{ printf "besu-node-validator-%d-pubkey" $index }}
80+
labels:
81+
{{- include "network-bootstrapper.labels" $root | nindent 4 }}
82+
data:
83+
publicKey: {{ $requiredPublicKey | quote }}
84+
---
85+
apiVersion: v1
86+
kind: Secret
87+
metadata:
88+
name: {{ printf "besu-node-validator-%d-private-key" $index }}
89+
labels:
90+
{{- include "network-bootstrapper.labels" $root | nindent 4 }}
91+
type: Opaque
92+
stringData:
93+
privateKey: {{ $requiredPrivateKey | quote }}
94+
{{- end }}
95+
---
96+
apiVersion: v1
97+
kind: ConfigMap
98+
metadata:
99+
name: besu-faucet-address
100+
labels:
101+
{{- include "network-bootstrapper.labels" . | nindent 4 }}
102+
data:
103+
address: {{ $faucet.address | quote }}
104+
---
105+
apiVersion: v1
106+
kind: ConfigMap
107+
metadata:
108+
name: besu-faucet-pubkey
109+
labels:
110+
{{- include "network-bootstrapper.labels" . | nindent 4 }}
111+
data:
112+
publicKey: {{ $faucet.publicKey | quote }}
113+
---
114+
apiVersion: v1
115+
kind: Secret
116+
metadata:
117+
name: besu-faucet-private-key
118+
labels:
119+
{{- include "network-bootstrapper.labels" . | nindent 4 }}
120+
type: Opaque
121+
stringData:
122+
privateKey: {{ $faucet.privateKey | quote }}
123+
{{- end }}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{- $artifactSource := default "generated" .Values.artifacts.source -}}
2+
{{- if eq $artifactSource "generated" }}
13
apiVersion: batch/v1
24
kind: Job
35
metadata:
@@ -106,3 +108,4 @@ spec:
106108
tolerations:
107109
{{- toYaml . | nindent 8 }}
108110
{{- end }}
111+
{{- end }}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,22 @@ settings:
121121
evmStackSize:
122122
# -- (int) Maximum smart-contract bytecode size accepted by the EVM.
123123
contractSizeLimit:
124+
125+
# Artifact sourcing controls for bootstrap data used by the nodes chart.
126+
artifacts:
127+
# -- (string) Determines how Besu network artifacts are populated. Use `generated` to run the job or `external` to supply values manually.
128+
source: generated
129+
external:
130+
# -- (object) Besu genesis document rendered into the `besu-genesis` ConfigMap when `source` equals `external`.
131+
genesis: {}
132+
# -- (list) Collection of enode URIs persisted to the `besu-static-nodes` ConfigMap when `source` equals `external`.
133+
staticNodes: []
134+
# -- (list) Validator node definitions providing the data expected by the nodes chart. Each entry must include `address`, `publicKey`, `privateKey`, and `enode`.
135+
validators: []
136+
faucet:
137+
# -- (string) Faucet account address stored in the `besu-faucet-address` ConfigMap when `source` equals `external`.
138+
address: ""
139+
# -- (string) Faucet account public key stored in the `besu-faucet-pubkey` ConfigMap when `source` equals `external`.
140+
publicKey: ""
141+
# -- (string) Faucet private key stored in the `besu-faucet-private-key` Secret when `source` equals `external`.
142+
privateKey: ""

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,6 @@ A Helm chart for Kubernetes
135135
| serviceAccount.create | bool | `true` | Create a ServiceAccount resource automatically for the release. |
136136
| serviceAccount.name | string | `""` | Existing ServiceAccount name to reuse when creation is disabled. |
137137
| tolerations | list | `[]` | Tolerations allowing pods to run on nodes with matching taints. |
138-
| validatorReplicaCount | int | `4` | Number of validator node replicas participating in consensus. |
138+
| validatorReplicaCount | int | `nil` | Number of validator node replicas participating in consensus. Leave unset to derive from global.validatorReplicaCount. |
139139
| volumeMounts | list | `[]` | Additional volume mounts applied to Besu containers. |
140140
| volumes | list | `[]` | Extra volumes attached to Besu pods for custom configuration or secrets. |

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,29 @@ Create the name of the service account to use
6060
{{- default "default" .Values.serviceAccount.name }}
6161
{{- end }}
6262
{{- end }}
63+
64+
{{/*
65+
Resolve the number of validator replicas, falling back to global overrides when provided.
66+
*/}}
67+
{{- define "nodes.validatorReplicaCount" -}}
68+
{{- $explicit := .Values.validatorReplicaCount -}}
69+
{{- if not (empty $explicit) -}}
70+
{{- $explicit | int -}}
71+
{{- else -}}
72+
{{- $global := default (dict) .Values.global -}}
73+
{{- $networkGlobal := dict -}}
74+
{{- if and (kindIs "map" $global) (hasKey $global "network") -}}
75+
{{- $networkCandidate := index $global "network" -}}
76+
{{- if kindIs "map" $networkCandidate -}}
77+
{{- $networkGlobal = $networkCandidate -}}
78+
{{- end -}}
79+
{{- end -}}
80+
{{- if and (kindIs "map" $networkGlobal) (hasKey $networkGlobal "validatorReplicaCount") -}}
81+
{{- (index $networkGlobal "validatorReplicaCount") | int -}}
82+
{{- else if and (kindIs "map" $global) (hasKey $global "validatorReplicaCount") -}}
83+
{{- (index $global "validatorReplicaCount") | int -}}
84+
{{- else -}}
85+
4
86+
{{- end -}}
87+
{{- end -}}
88+
{{- end }}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ spec:
2727
{{- $useClaimTemplate := and $persistenceEnabled (not $useExistingClaim) }}
2828
{{- $privateKeyFilename := default "privateKey" .Values.config.privateKeyFilename }}
2929
{{- $shouldMountPersistence := $persistenceEnabled }}
30-
{{- $validatorReplicaBudget := .Values.validatorReplicaCount | int }}
31-
replicas: {{ .Values.validatorReplicaCount }}
30+
{{- $validatorReplicaBudget := (include "nodes.validatorReplicaCount" . | int) }}
31+
replicas: {{ $validatorReplicaBudget }}
3232
serviceName: {{ include "nodes.fullname" . }}
3333
{{- if and $useClaimTemplate (or (ne $whenDeleted "") (ne $whenScaled "")) }}
3434
persistentVolumeClaimRetentionPolicy:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# -- (int) Number of RPC node replicas provisioned via StatefulSet.
44
rpcReplicaCount: 2
55

6-
# -- (int) Number of validator node replicas participating in consensus.
7-
validatorReplicaCount: 4
6+
# -- (int) Number of validator node replicas participating in consensus. Leave unset to derive from global.validatorReplicaCount.
7+
validatorReplicaCount:
88

99
# Container image configuration shared by validator and RPC pods.
1010
image:

0 commit comments

Comments
 (0)