Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(helm): add support to p2p #2212

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions deployments/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,17 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Build the p2p peer multiaddress string
*/}}
{{- define "p2p.bootstrapPeerMultiaddr" -}}
{{- if and .Values.p2p.enabled (not .Values.p2p.bootstrap) -}}
{{- $ip := .Values.p2p.nodeConfig.bootstrapServer.multiaddrIp -}}
{{- $port := .Values.p2p.nodeConfig.bootstrapServer.multiaddrPort -}}
{{- $uid := .Values.p2p.nodeConfig.bootstrapServer.multiaddrUid -}}
{{- printf "/ip4/%s/tcp/%s/p2p/%s" $ip $port $uid -}}
{{- else -}}
{{- "" -}}
{{- end -}}
{{- end -}}
41 changes: 36 additions & 5 deletions deployments/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ spec:
template:
metadata:
annotations:
{{- if .Values.deployment.annotations }}
{{ toYaml .Values.deployment.annotations | nindent 8 }}
{{- end}}
{{- if .Values.service.ports.monitoring.enabled }}
prometheus.io/scrape: "true"
prometheus.io/path: "/monitoring/metrics"
prometheus.io/port: {{ .Values.services.monitoring.port | quote }}
prometheus.io/port: {{ .Values.service.ports.monitoring.port | quote }}
{{- end }}
labels:
app: papyrus
{{- include "papyrus.selectorLabels" . | nindent 8 }}
Expand Down Expand Up @@ -57,11 +62,29 @@ spec:
cpu: {{ .Values.deployment.resources.requests.cpu | quote}}
memory: {{ .Values.deployment.resources.requests.memory }}
{{- if not .Values.backup.enabled }}
{{- with .Values.deployment.env }}
env:
{{- toYaml . | nindent 10 }}
{{- end }}
args:
- --config_file
- /app/config/presets/{{ .Values.starknet.preset }}
- --base_layer.node_url
- {{ .Values.base_layer_node_url }}
{{- if .Values.p2p.enabled }}
- --network.tcp_port
- {{ .Values.p2p.config.networkTcpPort | quote }}
- --storage.db_config.path_prefix
- {{ .Values.p2p.config.storageDbConfigPathPrefix | quote }}
- --network.#is_none
- {{ .Values.p2p.config.networkIsNone | quote }}
{{- if not .Values.p2p.bootstrap }}
- --network.bootstrap_peer_multiaddr.#is_none
- {{ .Values.p2p.nodeConfig.bootstrapServer.multiaddrIsNone | quote }}
- --network.bootstrap_peer_multiaddr
- {{ include "p2p.bootstrapPeerMultiaddr" . | quote }}
{{- end}}
{{- end }}
{{ range $key, $value := .Values.deployment.extraArgs }}
{{- if $value }}
- --{{ $key }}
Expand All @@ -70,10 +93,18 @@ spec:
- --{{ $key }}
{{- end }}
{{ end }}
{{- if .Values.services }}
ports:
- containerPort: {{ .Values.services.rpc.port }}
- containerPort: {{ .Values.services.monitoring.port }}
{{- if .Values.service.ports.rpc.enabled }}
- containerPort: {{ .Values.service.ports.rpc.port }}
name: rpc
{{- end }}
{{- if .Values.service.ports.monitoring.enabled }}
- containerPort: {{ .Values.service.ports.monitoring.port }}
name: monitoring
{{- end }}
{{- if .Values.p2p.enabled }}
- containerPort: {{ .Values.p2p.config.networkTcpPort }}
name: p2p
{{- end }}
volumeMounts:
- name: data
Expand All @@ -96,4 +127,4 @@ spec:
name: {{ template "papyrus.name" . }}-config
- secretRef:
name: {{ template "papyrus.name" . }}-aws-creds
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions deployments/helm/templates/p2p-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if and ( not .Values.backup.enabled ) .Values.p2p.service.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ template "papyrus.name" . }}-p2p
labels:
{{- include "papyrus.labels" . | nindent 4 }}
spec:
selector:
{{- include "papyrus.selectorLabels" . | nindent 6 }}
type: {{ .Values.p2p.service.type }}
ports:
- name: p2p
port: {{ .Values.p2p.service.port }}
protocol: {{ .Values.p2p.service.protocol }}
targetPort: p2p
{{- end }}
26 changes: 26 additions & 0 deletions deployments/helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if not .Values.backup.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ template "papyrus.name" . }}
labels:
{{- include "papyrus.labels" . | nindent 4 }}
spec:
selector:
{{- include "papyrus.selectorLabels" . | nindent 6 }}
type: {{ .Values.service.type }}
ports:
{{- if and .Values.service.ports.rpc .Values.service.ports.rpc.enabled }}
- name: rpc
port: {{ .Values.service.ports.rpc.port }}
protocol: {{ .Values.service.ports.rpc.protocol }}
targetPort: rpc
{{- end }}
{{- if and .Values.service.ports.monitoring .Values.service.ports.monitoring.enabled }}
- name: monitoring
port: {{ .Values.service.ports.monitoring.port }}
protocol: {{ .Values.service.ports.monitoring.protocol }}
targetPort: monitoring
{{- end }}
{{- end }}
20 changes: 0 additions & 20 deletions deployments/helm/templates/svc.yaml

This file was deleted.

76 changes: 58 additions & 18 deletions deployments/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,35 @@ base_layer_node_url:
starknet:
# possible values: "mainnet.json, sepolia_testnet" and "sepolia_integration".
preset: mainnet.json
additionalHeaders: # optional addtional headers for SN communication

p2p:
enabled: false
# Set to true if node act as bootstrap server
bootstrap: false
# General config
config:
# Optional - The node self port to listen
networkTcpPort: 10000
# Optional - The node data path
storageDbConfigPathPrefix: data
# Optional - network.#is_none flag
networkIsNone: false
# Config to include only if "bootstrap: false"
nodeConfig:
bootstrapServer:
# Mandatory - The network.#is_none flag on the bootsrap server
multiaddrIsNone:
# Mandatory - The bootstrap server ip address. If service is used, use the service address. If not, use the pod address.
multiaddrIp:
# Mandatory - The bootstrap server to connect to, port
multiaddrPort:
# Mandatory - The bootstrap server to connect to, uid
multiaddrUid:
service:
enabled: false
type: ClusterIP
port: 10000
protocol: TCP

deployment:
# The container image
Expand All @@ -22,10 +50,17 @@ deployment:
tag: 0.4.0
# The container's pullPolicy
pullPolicy: Always
# Optional - nodeSelector
nodeSelector:
# Optional - tolerations
tolerations:
# Set pod annotations
annotations: {}
# Set deployment nodeSelector
nodeSelector: {}
# Set deployment tolerations
tolerations: []
# - key: "key1"
# operator: "Equal"
# value: "value1"
# effect: "NoSchedule"

# The default resources for a pod.
resources:
limits:
Expand All @@ -34,26 +69,31 @@ deployment:
requests:
cpu: 500m
memory: 1Gi
## Optionally specify extra environment variables to add to papyrus container
env: []
# - name: FOO
# value: BAR
extraArgs: {} # Optional additional deployment args
# collect_metrics: "true"
# foo: "bar"

# Service variables for a papyrus pod.
services:
# RPC API.
rpc:
type: ClusterIP
port: 8080
protocol: TCP
# Monitoring API.
monitoring:
type: ClusterIP
port: 8081
protocol: TCP
service:
# Specify service type, supported options are ClusterIP, LoadBalancer
type: ClusterIP
ports:
rpc:
enabled: true
port: 8080
protocol: TCP
monitoring:
enabled: true
port: 8081
protocol: TCP

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