Skip to content

Commit 825056f

Browse files
committed
Add Mina test charts
1 parent bc848d0 commit 825056f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1408
-0
lines changed

mina-common/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: mina-test-common
3+
description: Common templates for Mina test nodes
4+
type: library
5+
version: 0.0.1
6+
appVersion: "0.0.0"

mina-common/templates/_ip.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{/*
2+
External service address
3+
*/}}
4+
{{- define "mina-common.service-external-ip" }}
5+
{{- $name := include "mina-common.fullname" . | upper }}
6+
{{- printf "$(%s_SERVICE_HOST)" (regexReplaceAll "[^A-Z_]" $name "_") }}
7+
{{- end }}

mina-common/templates/_name.tpl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "mina-common.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name. Usually this is used as a deployment or service name.
10+
*/}}
11+
{{- define "mina-common.fullname" -}}
12+
{{- if .Values.fullnameOverride }}
13+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14+
{{- else }}
15+
{{- $name := default .Chart.Name .Values.nameOverride }}
16+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
17+
{{- end }}
18+
{{- end }}
19+
20+
{{/*
21+
Creates a DNS-compatible name qualified with the release name
22+
*/}}
23+
{{- define "mina-common.qname" }}
24+
{{ $name := index . 0 }}
25+
{{ $ := index . 1 }}
26+
{{ printf "%s-%s" $.Release.Name $name | trunc 63 | trimSuffix "-" }}
27+
{{- end }}

mina-common/templates/_peers.tpl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{/*
2+
Multiaddress of a peer
3+
*/}}
4+
{{- define "mina-common.peers.multiAddress" }}
5+
{{- $name := include "mina-common.peers.dnsName" . }}
6+
{{- $port := default "8302" .Peer.port }}
7+
{{- $peerid := .Peer.peerId }}
8+
{{- printf "/dns4/%s/tcp/%s/p2p/%s" $name $port $peerid }}
9+
{{- end }}
10+
11+
{{/*
12+
Peer DNS name (usually service name).
13+
Assumes that the peer description is in .Values.Peer
14+
*/}}
15+
{{- define "mina-common.peers.dnsName" }}
16+
{{- if .Peer.fullName }}
17+
{{- .Peer.fullName -}}
18+
{{- else }}
19+
{{- include "mina-common.qname" (list .Peer.name .) | trim }}
20+
{{- end }}
21+
{{- end }}

ocaml-test-node/Chart.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: mina-test-common
3+
repository: file://../mina-common
4+
version: 0.0.1
5+
digest: sha256:c13c24e4a92368b1f1015144292e55432c5e0a23c1a2b6fa63c9b2e8bdfe3ff4
6+
generated: "2023-11-13T12:34:00.297609804+03:00"

ocaml-test-node/Chart.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v2
2+
name: ocaml-test-node
3+
description: A Helm chart for OCaml Mina test node.
4+
type: application
5+
version: 0.0.1
6+
7+
# This is the version number of the application being deployed. This version number should be
8+
# incremented each time you make changes to the application. Versions are not expected to
9+
# follow Semantic Versioning. They should reflect the version the application is using.
10+
# It is recommended to use it with quotes.
11+
appVersion: "2.0.0rampup4"
12+
13+
dependencies:
14+
- name: mina-test-common
15+
repository: file://../mina-common
16+
version: ">=0.0.0"

ocaml-test-node/templates/NOTES.txt

Whitespace-only changes.

ocaml-test-node/templates/_args.tpl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{/*
2+
Mina arguments
3+
*/}}
4+
{{- define "ocaml-test-node.args" -}}[
5+
{{ include "ocaml-test-node.args.common" . }}
6+
{{ include "ocaml-test-node.peers.args" . }}
7+
{{ include "ocaml-test-node.args.demoMode" . }}
8+
{{ include "ocaml-test-node.args.blockProducer" . }}
9+
{{ include "ocaml-test-node.args.values" . }}
10+
]
11+
{{- end }}
12+
13+
{{/*
14+
Common Mina arguments
15+
*/}}
16+
{{- define "ocaml-test-node.args.common" -}}
17+
"--log-level", "Debug",
18+
"--insecure-rest-server",
19+
"--config-file", {{ include "ocaml-test-node.daemonJson.path" . | quote }},
20+
"--libp2p-keypair", {{ include "ocaml-test-node.libp2p.path" . | quote }},
21+
{{- if .Values.isSeed }}
22+
"--seed",
23+
{{- end }}
24+
"--external-ip", {{ include "mina-common.service-external-ip" . | quote }},
25+
{{- end -}}
26+
27+
{{/*
28+
Mina arguments for demo mode
29+
*/}}
30+
{{- define "ocaml-test-node.args.demoMode" -}}
31+
{{- if .Values.demoMode -}}
32+
--demo-mode,
33+
{{- end -}}
34+
{{- end -}}
35+
36+
{{/*
37+
Mina arguments for block production mode
38+
*/}}
39+
{{- define "ocaml-test-node.args.blockProducer" -}}
40+
{{- if .Values.blockProducer -}}
41+
--blockProductionKey, {{ include "ocaml-test-node.blockProducerKey.path" . }}
42+
{{- end -}}
43+
{{- end -}}
44+
45+
{{/*
46+
Mina arguments specified in .Values
47+
*/}}
48+
{{- define "ocaml-test-node.args.values" }}
49+
{{- range .Values.args }}
50+
{{ . | quote }},
51+
{{- end }}
52+
{{- end }}
53+
54+
{{/*
55+
Mina external
56+
*/}}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{{/*
2+
Full block production key path
3+
*/}}
4+
{{- define "ocaml-test-node.blockProducerKey.path" -}}
5+
{{- include "ocaml-test-node.blockProducerKey.volumeMount.path" . }}/{{ include "ocaml-test-node.blockProducerKey.name" . }}
6+
{{- end }}
7+
8+
{{/*
9+
Mount point of block production keys
10+
*/}}
11+
{{- define "ocaml-test-node.blockProducerKey.volumeMount.path" -}}
12+
/keys
13+
{{- end }}
14+
15+
{{/*
16+
Block production key file name
17+
*/}}
18+
{{- define "ocaml-test-node.blockProducerKey.name" -}}
19+
.block-producer
20+
{{- end }}
21+
22+
{{/*
23+
Block producer key init containers (none)
24+
*/}}
25+
{{- define "ocaml-test-node.blockProducerKey.initContainers" }}{{ end -}}
26+
27+
{{/*
28+
Block producer volume mount
29+
*/}}
30+
{{- define "ocaml-test-node.blockProducerKey.volumeMounts" }}
31+
{{- if .Values.blockProducerKey.secret }}
32+
- name: {{ include "ocaml-test-node.blockProducerKey.volume.name" }}
33+
mountPath: {{ include "ocaml-test-node.blockProducerKey.volumeMount.path" . }}
34+
{{- end }}
35+
{{- end }}
36+
37+
{{/*
38+
Block producer key volume
39+
*/}}
40+
{{- define "ocaml-test-node.blockProducerKey.volume.name" }}block-producer-key{{ end }}
41+
42+
{{/*
43+
Block producer key volume
44+
*/}}
45+
{{- define "ocaml-test-node.blockProducerKey.volume" }}
46+
{{- if .Values.blockProducerKey.secret }}
47+
- name: {{ include "ocaml-test-node.blockProducerKey.volume.name" }}
48+
secret:
49+
secretName: {{ .Values.blockProducerKey.secret }}
50+
items:
51+
- key: key
52+
path: {{ .Values.blockProducerKey.file.name }}
53+
{{- end }}
54+
{{- end }}

ocaml-test-node/templates/_common.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{/*
2+
Mina image
3+
*/}}
4+
{{- define "ocaml-test-node.image" -}}
5+
{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
6+
{{- end }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{{/*
2+
Path to daemon.json config file
3+
*/}}
4+
{{- define "ocaml-test-node.daemonJson.path" -}}
5+
{{ include "ocaml-test-node.daemonJson.volumeMount.path" . }}/{{ include "ocaml-test-node.daemonJson.file.name" . }}
6+
{{- end }}
7+
8+
{{/*
9+
Mount point of block production keys
10+
*/}}
11+
{{- define "ocaml-test-node.daemonJson.volumeMount.path" -}}
12+
/config
13+
{{- end }}
14+
15+
{{/*
16+
Block production key file name
17+
*/}}
18+
{{- define "ocaml-test-node.daemonJson.file.name" -}}
19+
daemon.json
20+
{{- end }}
21+
22+
{{/*
23+
Init containers for daemon.json
24+
*/}}
25+
{{- define "ocaml-test-node.daemonJson.initContainers" -}}
26+
{{- include "ocaml-test-node.daemonJson.fetchContainer" . }}
27+
{{- end }}
28+
29+
{{/*
30+
Init container for daemon.json
31+
*/}}
32+
{{- define "ocaml-test-node.daemonJson.fetchContainer" }}
33+
{{- if .Values.daemonJson.remote }}
34+
- name: daemon-json-download
35+
image: alpine
36+
command: [ "sh", "-c" ]
37+
args:
38+
- curl -o {{ include "ocaml-test-node.daemonJson.path" . }} {{ .Values.daemonJson.remote.url }}
39+
volumeMounts:
40+
- name: {{ include "ocaml-test-node.daemonJson.volume.name" . }}
41+
mountPath: {{ include "ocaml-test-node.daemonJson.volumeMount.path" . }}
42+
{{- else if .Values.daemonJson.local }}
43+
- name: daemon-json-copy
44+
image: {{ include "ocaml-test-node.image" . }}
45+
command: [ "sh", "-c" ]
46+
args:
47+
- cp {{ .Values.daemonJson.local.path }} {{ include "ocaml-test-node.daemonJson.path" . }}
48+
volumeMounts:
49+
- name: {{ include "ocaml-test-node.daemonJson.volume.name" . }}
50+
mountPath: {{ include "ocaml-test-node.daemonJson.volumeMount.path" . }}
51+
{{- end }}
52+
{{- end }}
53+
54+
55+
{{/*
56+
Config volume mount
57+
*/}}
58+
{{- define "ocaml-test-node.daemonJson.volumeMounts" }}
59+
- name: {{ include "ocaml-test-node.daemonJson.volume.name" . }}
60+
mountPath: {{ include "ocaml-test-node.daemonJson.volumeMount.path" . }}
61+
{{- end }}
62+
63+
{{/*
64+
Config volume (containing daemon.json)
65+
*/}}
66+
{{- define "ocaml-test-node.daemonJson.volume.name" }}daemon-json{{ end }}
67+
68+
{{/*
69+
Config volume (containing daemon.json)
70+
*/}}
71+
{{- define "ocaml-test-node.daemonJson.volume" }}
72+
- name: {{ include "ocaml-test-node.daemonJson.volume.name" . }}
73+
{{- if .Values.daemonJson.secret }}
74+
secret:
75+
name: {{ .Values.daemonJson.secret }}
76+
items: [ daemon.json ]
77+
{{- else }}
78+
emptyDir: {}
79+
{{- end }}
80+
{{- end }}

ocaml-test-node/templates/_env.tpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{/*
2+
Mina env
3+
*/}}
4+
{{- define "ocaml-test-node.env" }}
5+
- name: "MINA_LIBP2P_PASS"
6+
value: ""
7+
- name: "MINA_PRIVKEY_PASS"
8+
value: ""
9+
{{- end }}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "ocaml-test-node.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "ocaml-test-node.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
19+
{{- end }}
20+
{{- end }}
21+
22+
{{/*
23+
Create chart name and version as used by the chart label.
24+
*/}}
25+
{{- define "ocaml-test-node.chart" -}}
26+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
27+
{{- end }}
28+
29+
{{/*
30+
Common labels
31+
*/}}
32+
{{- define "ocaml-test-node.labels" -}}
33+
helm.sh/chart: {{ include "ocaml-test-node.chart" . }}
34+
{{ include "ocaml-test-node.selectorLabels" . }}
35+
{{- if .Chart.AppVersion }}
36+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
37+
{{- end }}
38+
app.kubernetes.io/managed-by: {{ .Release.Service }}
39+
openmina.com/node-kind: ocaml
40+
{{- end }}
41+
42+
{{/*
43+
Pod labels
44+
*/}}
45+
{{- define "ocaml-test-node.podLabels" -}}
46+
openmina.com/node-kind: ocaml
47+
{{- end }}
48+
49+
{{/*
50+
Selector labels
51+
*/}}
52+
{{- define "ocaml-test-node.selectorLabels" -}}
53+
app.kubernetes.io/name: {{ include "ocaml-test-node.name" . }}
54+
app.kubernetes.io/instance: {{ .Release.Name }}
55+
{{- end }}
56+
57+
{{/*
58+
Create the name of the service account to use
59+
*/}}
60+
{{- define "ocaml-test-node.serviceAccountName" -}}
61+
{{- if .Values.serviceAccount.create }}
62+
{{- default (include "ocaml-test-node.fullname" .) .Values.serviceAccount.name }}
63+
{{- else }}
64+
{{- default "default" .Values.serviceAccount.name }}
65+
{{- end }}
66+
{{- end }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{/*
2+
All init containers
3+
*/}}
4+
{{- define "ocaml-test-node.initContainers" }}
5+
{{ include "ocaml-test-node.daemonJson.initContainers" . }}
6+
{{ include "ocaml-test-node.libp2p.initContainers" . }}
7+
{{ include "ocaml-test-node.blockProducerKey.initContainers" . }}
8+
{{- if (and (not .Values.seed) (gt (int .Values.seedWaitTimeout) 0))}}
9+
- name: wait
10+
image: busybox
11+
command: ["sh", "-c", "sleep {{ .Values.seedWaitTimeout }}"]
12+
{{- end }}
13+
{{- end }}

0 commit comments

Comments
 (0)