Skip to content
This repository was archived by the owner on Dec 26, 2024. It is now read-only.

Commit 3bb9411

Browse files
feat(helm): add support to p2p (#2212)
* chore(helm): add support to p2p * fix(helm): removed default values from templates * fix(helm): added required mandatory fake values for helm install ci test to pass * fix(helm): changed default values
1 parent 9a6175e commit 3bb9411

File tree

6 files changed

+152
-43
lines changed

6 files changed

+152
-43
lines changed

Diff for: deployments/helm/templates/_helpers.tpl

+14
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,17 @@ Create the name of the service account to use
6060
{{- default "default" .Values.serviceAccount.name }}
6161
{{- end }}
6262
{{- end }}
63+
64+
{{/*
65+
Build the p2p peer multiaddress string
66+
*/}}
67+
{{- define "p2p.bootstrapPeerMultiaddr" -}}
68+
{{- if and .Values.p2p.enabled (not .Values.p2p.bootstrap) -}}
69+
{{- $ip := .Values.p2p.nodeConfig.bootstrapServer.multiaddrIp -}}
70+
{{- $port := .Values.p2p.nodeConfig.bootstrapServer.multiaddrPort -}}
71+
{{- $uid := .Values.p2p.nodeConfig.bootstrapServer.multiaddrUid -}}
72+
{{- printf "/ip4/%s/tcp/%s/p2p/%s" $ip $port $uid -}}
73+
{{- else -}}
74+
{{- "" -}}
75+
{{- end -}}
76+
{{- end -}}

Diff for: deployments/helm/templates/deployment.yaml

+36-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ spec:
1818
template:
1919
metadata:
2020
annotations:
21+
{{- if .Values.deployment.annotations }}
22+
{{ toYaml .Values.deployment.annotations | nindent 8 }}
23+
{{- end}}
24+
{{- if .Values.service.ports.monitoring.enabled }}
2125
prometheus.io/scrape: "true"
2226
prometheus.io/path: "/monitoring/metrics"
23-
prometheus.io/port: {{ .Values.services.monitoring.port | quote }}
27+
prometheus.io/port: {{ .Values.service.ports.monitoring.port | quote }}
28+
{{- end }}
2429
labels:
2530
app: papyrus
2631
{{- include "papyrus.selectorLabels" . | nindent 8 }}
@@ -57,11 +62,29 @@ spec:
5762
cpu: {{ .Values.deployment.resources.requests.cpu | quote}}
5863
memory: {{ .Values.deployment.resources.requests.memory }}
5964
{{- if not .Values.backup.enabled }}
65+
{{- with .Values.deployment.env }}
66+
env:
67+
{{- toYaml . | nindent 10 }}
68+
{{- end }}
6069
args:
6170
- --config_file
6271
- /app/config/presets/{{ .Values.starknet.preset }}
6372
- --base_layer.node_url
6473
- {{ .Values.base_layer_node_url }}
74+
{{- if .Values.p2p.enabled }}
75+
- --network.tcp_port
76+
- {{ .Values.p2p.config.networkTcpPort | quote }}
77+
- --storage.db_config.path_prefix
78+
- {{ .Values.p2p.config.storageDbConfigPathPrefix | quote }}
79+
- --network.#is_none
80+
- {{ .Values.p2p.config.networkIsNone | quote }}
81+
{{- if not .Values.p2p.bootstrap }}
82+
- --network.bootstrap_peer_multiaddr.#is_none
83+
- {{ .Values.p2p.nodeConfig.bootstrapServer.multiaddrIsNone | quote }}
84+
- --network.bootstrap_peer_multiaddr
85+
- {{ include "p2p.bootstrapPeerMultiaddr" . | quote }}
86+
{{- end}}
87+
{{- end }}
6588
{{ range $key, $value := .Values.deployment.extraArgs }}
6689
{{- if $value }}
6790
- --{{ $key }}
@@ -70,10 +93,18 @@ spec:
7093
- --{{ $key }}
7194
{{- end }}
7295
{{ end }}
73-
{{- if .Values.services }}
7496
ports:
75-
- containerPort: {{ .Values.services.rpc.port }}
76-
- containerPort: {{ .Values.services.monitoring.port }}
97+
{{- if .Values.service.ports.rpc.enabled }}
98+
- containerPort: {{ .Values.service.ports.rpc.port }}
99+
name: rpc
100+
{{- end }}
101+
{{- if .Values.service.ports.monitoring.enabled }}
102+
- containerPort: {{ .Values.service.ports.monitoring.port }}
103+
name: monitoring
104+
{{- end }}
105+
{{- if .Values.p2p.enabled }}
106+
- containerPort: {{ .Values.p2p.config.networkTcpPort }}
107+
name: p2p
77108
{{- end }}
78109
volumeMounts:
79110
- name: data
@@ -96,4 +127,4 @@ spec:
96127
name: {{ template "papyrus.name" . }}-config
97128
- secretRef:
98129
name: {{ template "papyrus.name" . }}-aws-creds
99-
{{- end }}
130+
{{- end }}

Diff for: deployments/helm/templates/p2p-service.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if and ( not .Values.backup.enabled ) .Values.p2p.service.enabled }}
2+
---
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: {{ template "papyrus.name" . }}-p2p
7+
labels:
8+
{{- include "papyrus.labels" . | nindent 4 }}
9+
spec:
10+
selector:
11+
{{- include "papyrus.selectorLabels" . | nindent 6 }}
12+
type: {{ .Values.p2p.service.type }}
13+
ports:
14+
- name: p2p
15+
port: {{ .Values.p2p.service.port }}
16+
protocol: {{ .Values.p2p.service.protocol }}
17+
targetPort: p2p
18+
{{- end }}

Diff for: deployments/helm/templates/service.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- if not .Values.backup.enabled }}
2+
---
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: {{ template "papyrus.name" . }}
7+
labels:
8+
{{- include "papyrus.labels" . | nindent 4 }}
9+
spec:
10+
selector:
11+
{{- include "papyrus.selectorLabels" . | nindent 6 }}
12+
type: {{ .Values.service.type }}
13+
ports:
14+
{{- if and .Values.service.ports.rpc .Values.service.ports.rpc.enabled }}
15+
- name: rpc
16+
port: {{ .Values.service.ports.rpc.port }}
17+
protocol: {{ .Values.service.ports.rpc.protocol }}
18+
targetPort: rpc
19+
{{- end }}
20+
{{- if and .Values.service.ports.monitoring .Values.service.ports.monitoring.enabled }}
21+
- name: monitoring
22+
port: {{ .Values.service.ports.monitoring.port }}
23+
protocol: {{ .Values.service.ports.monitoring.protocol }}
24+
targetPort: monitoring
25+
{{- end }}
26+
{{- end }}

Diff for: deployments/helm/templates/svc.yaml

-20
This file was deleted.

Diff for: deployments/helm/values.yaml

+58-18
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,35 @@ base_layer_node_url:
1313
starknet:
1414
# possible values: "mainnet.json, sepolia_testnet" and "sepolia_integration".
1515
preset: mainnet.json
16-
additionalHeaders: # optional addtional headers for SN communication
16+
17+
p2p:
18+
enabled: false
19+
# Set to true if node act as bootstrap server
20+
bootstrap: false
21+
# General config
22+
config:
23+
# Optional - The node self port to listen
24+
networkTcpPort: 10000
25+
# Optional - The node data path
26+
storageDbConfigPathPrefix: data
27+
# Optional - network.#is_none flag
28+
networkIsNone: false
29+
# Config to include only if "bootstrap: false"
30+
nodeConfig:
31+
bootstrapServer:
32+
# Mandatory - The network.#is_none flag on the bootsrap server
33+
multiaddrIsNone:
34+
# Mandatory - The bootstrap server ip address. If service is used, use the service address. If not, use the pod address.
35+
multiaddrIp:
36+
# Mandatory - The bootstrap server to connect to, port
37+
multiaddrPort:
38+
# Mandatory - The bootstrap server to connect to, uid
39+
multiaddrUid:
40+
service:
41+
enabled: false
42+
type: ClusterIP
43+
port: 10000
44+
protocol: TCP
1745

1846
deployment:
1947
# The container image
@@ -22,10 +50,17 @@ deployment:
2250
tag: 0.4.0
2351
# The container's pullPolicy
2452
pullPolicy: Always
25-
# Optional - nodeSelector
26-
nodeSelector:
27-
# Optional - tolerations
28-
tolerations:
53+
# Set pod annotations
54+
annotations: {}
55+
# Set deployment nodeSelector
56+
nodeSelector: {}
57+
# Set deployment tolerations
58+
tolerations: []
59+
# - key: "key1"
60+
# operator: "Equal"
61+
# value: "value1"
62+
# effect: "NoSchedule"
63+
2964
# The default resources for a pod.
3065
resources:
3166
limits:
@@ -34,26 +69,31 @@ deployment:
3469
requests:
3570
cpu: 500m
3671
memory: 1Gi
72+
## Optionally specify extra environment variables to add to papyrus container
73+
env: []
74+
# - name: FOO
75+
# value: BAR
3776
extraArgs: {} # Optional additional deployment args
38-
# collect_metrics: "true"
77+
# foo: "bar"
3978

4079
# Service variables for a papyrus pod.
41-
services:
42-
# RPC API.
43-
rpc:
44-
type: ClusterIP
45-
port: 8080
46-
protocol: TCP
47-
# Monitoring API.
48-
monitoring:
49-
type: ClusterIP
50-
port: 8081
51-
protocol: TCP
80+
service:
81+
# Specify service type, supported options are ClusterIP, LoadBalancer
82+
type: ClusterIP
83+
ports:
84+
rpc:
85+
enabled: true
86+
port: 8080
87+
protocol: TCP
88+
monitoring:
89+
enabled: true
90+
port: 8081
91+
protocol: TCP
5292

5393
# Persistent volume claim variables for a papyrus pod.
5494
pvc:
5595
# Recommended size is at least 512Gi.
56-
size:
96+
size: 512Gi
5797
# Is is recommended to use an SSD volume (such as GKE premium-rwo).
5898
storageClass: ""
5999
# Use an existing snapshot for the node's data. The kubernetes volumesnapshot object should

0 commit comments

Comments
 (0)