Skip to content

Commit

Permalink
feat: add configs to allow to start node as a solo relaychain node MG…
Browse files Browse the repository at this point in the history
  • Loading branch information
tenequm authored Jan 25, 2024
1 parent e18f107 commit 533b2e6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
2 changes: 2 additions & 0 deletions charts/node/templates/service-monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ spec:
path: /metrics
honorLabels: true
interval: 30s
{{- if .Values.isParachain }}
- targetPort: prom-relaychain
path: /metrics
honorLabels: true
interval: 30s
{{- end }}
{{- if .Values.wsHealthExporter.enabled }}
- targetPort: http-ws-health
honorLabels: true
Expand Down
2 changes: 2 additions & 0 deletions charts/node/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ spec:
name: rpc
- port: 9615
name: prometheus
{{- if .Values.isParachain }}
- port: 9625
name: prom-relaychain
{{- end }}
{{- if .Values.wsHealthExporter.enabled }}
- port: 8001
name: http-ws-health
Expand Down
45 changes: 38 additions & 7 deletions charts/node/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ spec:
- mountPath: /chain-data
name: chain-data
{{- end }}
{{- if .Values.isParachain }}
{{- if .Values.relaychain.chainData.snapshotUrl }}
- name: download-relay-chain-snapshot
image: {{ .Values.initContainer.image.repository }}:{{ .Values.initContainer.image.tag }}
Expand Down Expand Up @@ -82,6 +83,7 @@ spec:
- mountPath: /relaychain-data
name: relaychain-data
{{- end }}
{{- end }}
{{- if or .Values.customChainspecUrl .Values.relaychain.customChainspecUrl}}
- name: download-chainspec
image: {{ .Values.initContainer.image.repository }}:{{ .Values.initContainer.image.tag }}
Expand All @@ -99,6 +101,7 @@ spec:
fi
{{- end }}
{{- end }}
{{- if .Values.isParachain }}
{{- if .Values.relaychain.customChainspecUrl }}
{{- if not .Values.forceDownloadChainspec }}
if [ ! -f {{ .Values.relaychain.chainspecPath }} ]; then
Expand All @@ -108,11 +111,14 @@ spec:
fi
{{- end }}
{{- end }}
{{- end }}
volumeMounts:
- mountPath: /chain-data
name: chain-data
{{- if .Values.isParachain }}
- mountPath: /relaychain-data
name: relaychain-data
{{- end }}
securityContext:
runAsUser: 0
{{- else }}
Expand All @@ -131,10 +137,15 @@ spec:
fi
{{- end }}
volumeMounts:
- mountPath: /chain-data
name: chain-data
{{- if .Values.isParachain }}
- mountPath: /relaychain-data
name: relaychain-data
{{- end }}
securityContext:
runAsUser: 0
{{- if .Values.isParachain }}
- name: export-genesis-wasm-and-state
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command: ["/bin/bash"]
Expand All @@ -148,6 +159,7 @@ spec:
- mountPath: /chain-data
name: chain-data
{{- end }}
{{- end }}
{{- if .Values.accountKeys }}
- name: inject-keys
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand All @@ -161,7 +173,7 @@ spec:
echo "Error: File /var/run/secrets/{{ .type }}/type does not exist"
exit 1
fi
{{ $.Values.command }} key insert --chain {{ if $.Values.customChainspecUrl }}{{ $.Values.customChainspecPath }}{{ else }}{{ $.Values.chain }}{{ end }} \
{{ $.Values.command }} key insert --chain {{ if or $.Values.customChainspecUrl $.Values.forceCustomChainspecPath }}{{ $.Values.customChainspecPath }}{{ else }}{{ $.Values.chain }}{{ end }} \
--keystore-path /keystore \
--key-type $(cat /var/run/secrets/{{ .type }}/type) \
--scheme $(cat /var/run/secrets/{{ .type }}/scheme) \
Expand All @@ -178,6 +190,7 @@ spec:
&& echo "Generated node key into Keystore" \
|| echo "Failed to generate and insert node key into Keystore."
fi
{{- if .Values.isParachain }}
RELAYCHAIN_NODE_KEY_PATH="/relaychain-keystore/node-key"
if [ -f "${RELAYCHAIN_NODE_KEY_PATH}" ]; then
echo "Relaychain node key already exists, skipping node key generation"
Expand All @@ -186,13 +199,16 @@ spec:
&& echo "Generated relaychain node key into relaychain Keystore" \
|| echo "Failed to generate and insert node key into relaychain Keystore."
fi
{{- end }}
volumeMounts:
- mountPath: /chain-data
name: chain-data
- mountPath: /keystore
name: chain-keystore
{{- if .Values.isParachain }}
- mountPath: /relaychain-keystore
name: relaychain-keystore
{{- end }}
{{- range $keys := .Values.accountKeys }}
- mountPath: /var/run/secrets/{{ .type }}
name: {{ .type }}
Expand All @@ -206,10 +222,9 @@ spec:
image: "{{ .Values.image.repository}}:{{ .Values.image.tag }}"
imagePullPolicy: Always
command:
# parachain
- {{ .Values.command }}
- --name={{ default (include "node.name" .) .Values.nodeNameOverride }}
- --chain={{ if .Values.customChainspecUrl }}{{ .Values.customChainspecPath }}{{ else }}{{ .Values.chain }}{{ end }}
- --chain={{ if or .Values.customChainspecUrl .Values.forceCustomChainspecPath }}{{ .Values.customChainspecPath }}{{ else }}{{ .Values.chain }}{{ end }}
{{- if .Values.isCollator }}
- --collator
{{- end }}
Expand Down Expand Up @@ -245,13 +260,14 @@ spec:
{{- end }}
- --rpc-cors=all
{{- if .Values.jaegerAgent.enabled }}
--jaeger-agent=127.0.0.1:{{ .Values.jaegerAgent.ports.compactPort }} \
- --jaeger-agent=127.0.0.1:{{ .Values.jaegerAgent.ports.compactPort }}
{{- end }}
{{- range .Values.extraArgs }}
- {{ . }}
{{- end }}
{{- if .Values.isParachain }}
# relaychain params
- --
# relaychain
- --name={{ default (include "node.name" .) .Values.nodeNameOverride }}
{{- if .Values.relaychain.bootnodeAddr }}
- --bootnodes={{ .Values.relaychain.bootnodeAddr }}
Expand All @@ -273,17 +289,20 @@ spec:
{{- range .Values.relaychain.extraArgs }}
- {{ . }}
{{- end }}
{{- end }}
ports:
- containerPort: 9944
name: rpc
- containerPort: 9615
name: prometheus
- containerPort: 9625
name: prom-relaychain
- containerPort: 30333
name: p2p
{{- if .Values.isParachain }}
- containerPort: 30334
name: p2p-relaychain
- containerPort: 9625
name: prom-relaychain
{{- end }}
env:
{{- range $key, $val := .Values.env }}
- name: {{ $key }}
Expand All @@ -296,10 +315,12 @@ spec:
name: chain-data
- mountPath: /keystore
name: chain-keystore
{{- if .Values.isParachain }}
- mountPath: /relaychain-data
name: relaychain-data
- mountPath: /relaychain-keystore
name: relaychain-keystore
{{- end }}
{{- if .Values.enableStartupProbe }}
startupProbe:
failureThreshold: 30
Expand Down Expand Up @@ -436,6 +457,10 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if or .Values.accountKeys .Values.keystoreMountInMemoryEnabled }}
volumes:
{{- range $keys := .Values.accountKeys }}
Expand All @@ -452,12 +477,14 @@ spec:
{{- if and (.Values.keystoreMountInMemorySizeLimit) (semverCompare ">=1.22-0" .Capabilities.KubeVersion.GitVersion) }}
sizeLimit: {{ .Values.keystoreMountInMemorySizeLimit }}
{{- end }}
{{- if .Values.isParachain }}
- name: relaychain-keystore
emptyDir:
medium: "Memory"
{{- if and (.Values.keystoreMountInMemorySizeLimit) (semverCompare ">=1.22-0" .Capabilities.KubeVersion.GitVersion) }}
sizeLimit: {{ .Values.keystoreMountInMemorySizeLimit }}
{{- end }}
{{- end }}
{{- end }}
volumeClaimTemplates:
- metadata:
Expand All @@ -479,6 +506,7 @@ spec:
resources:
requests:
storage: {{ .Values.storageSize }}
{{- if .Values.isParachain }}
- metadata:
name: relaychain-data
spec:
Expand All @@ -498,6 +526,7 @@ spec:
resources:
requests:
storage: {{ .Values.relaychain.storageSize }}
{{- end }}
{{- if not .Values.keystoreMountInMemoryEnabled }}
- metadata:
name: chain-keystore
Expand All @@ -507,6 +536,7 @@ spec:
resources:
requests:
storage: {{ .Values.keystoreStorageSize }}
{{- if .Values.isParachain }}
- metadata:
name: relaychain-keystore
spec:
Expand All @@ -516,3 +546,4 @@ spec:
requests:
storage: {{ .Values.keystoreStorageSize }}
{{- end }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ image:
## Overrides the image tag whose default is the chart appVersion.
tag: develop

# Defines if node should run as a parachain node
isParachain: true

isCollator: true
# Role gets assigned to resources as a label
role: full
Expand All @@ -37,6 +40,7 @@ chain: public-testnet
allowUnsafeRpcMethods: true
telemetryUrls: []
customChainspecPath: "/chain-data/chainspec.json"
forceCustomChainspecPath: false
## When defined, chainspec will be downloaded from the URL.
## By default `chain` variable value is passed to node's `--chain` parameter.
# customChainspecUrl:
Expand Down Expand Up @@ -115,6 +119,8 @@ terminationGracePeriodSeconds: 60
tolerations: []
# -- Assign custom affinity rules
affinity: {}
# -- Assign custom securityContext rules for containers
securityContext: {}

initContainer:
image:
Expand Down

0 comments on commit 533b2e6

Please sign in to comment.