From 19d994a950577e4834c69681d2c578d16740cf2b Mon Sep 17 00:00:00 2001 From: Idan Shamam Date: Tue, 9 Jul 2024 18:10:16 +0300 Subject: [PATCH 1/4] chore(helm): add support to p2p --- deployments/helm/templates/_helpers.tpl | 14 ++++ deployments/helm/templates/deployment.yaml | 41 ++++++++++-- deployments/helm/templates/p2p-service.yaml | 18 +++++ deployments/helm/templates/service.yaml | 26 ++++++++ deployments/helm/templates/svc.yaml | 20 ------ deployments/helm/values.yaml | 73 ++++++++++++++++----- 6 files changed, 151 insertions(+), 41 deletions(-) create mode 100644 deployments/helm/templates/p2p-service.yaml create mode 100644 deployments/helm/templates/service.yaml delete mode 100644 deployments/helm/templates/svc.yaml diff --git a/deployments/helm/templates/_helpers.tpl b/deployments/helm/templates/_helpers.tpl index 9b6c563648..eef0f98ec6 100644 --- a/deployments/helm/templates/_helpers.tpl +++ b/deployments/helm/templates/_helpers.tpl @@ -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 -}} \ No newline at end of file diff --git a/deployments/helm/templates/deployment.yaml b/deployments/helm/templates/deployment.yaml index b3b5f379cd..8cdd36ff29 100644 --- a/deployments/helm/templates/deployment.yaml +++ b/deployments/helm/templates/deployment.yaml @@ -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 }} @@ -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 12 }} + {{- 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 + - {{ default "10000" .Values.p2p.config.networkTcpPort | quote }} + - --storage.db_config.path_prefix + - {{ default "data" .Values.p2p.config.storageDbConfigPathPrefix | quote }} + - --network.#is_none + - {{ default false .Values.p2p.config.networkIsNone | quote }} + {{- if not .Values.p2p.bootstrap }} + - --network.bootstrap_peer_multiaddr.#is_none + - {{ default false .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 }} @@ -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: {{ default 10000 .Values.p2p.config.networkTcpPort }} + name: p2p {{- end }} volumeMounts: - name: data @@ -96,4 +127,4 @@ spec: name: {{ template "papyrus.name" . }}-config - secretRef: name: {{ template "papyrus.name" . }}-aws-creds - {{- end }} + {{- end }} \ No newline at end of file diff --git a/deployments/helm/templates/p2p-service.yaml b/deployments/helm/templates/p2p-service.yaml new file mode 100644 index 0000000000..f8435115fa --- /dev/null +++ b/deployments/helm/templates/p2p-service.yaml @@ -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 }} \ No newline at end of file diff --git a/deployments/helm/templates/service.yaml b/deployments/helm/templates/service.yaml new file mode 100644 index 0000000000..1b073cf3f0 --- /dev/null +++ b/deployments/helm/templates/service.yaml @@ -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 }} \ No newline at end of file diff --git a/deployments/helm/templates/svc.yaml b/deployments/helm/templates/svc.yaml deleted file mode 100644 index 83890adb6a..0000000000 --- a/deployments/helm/templates/svc.yaml +++ /dev/null @@ -1,20 +0,0 @@ -{{- if not .Values.backup.enabled }} -{{- range $k, $v := .Values.services }} ---- -apiVersion: v1 -kind: Service -metadata: - name: {{ template "papyrus.name" $ }}-{{ $k }} - labels: - {{- include "papyrus.labels" $ | nindent 4 }} -spec: - selector: - {{- include "papyrus.selectorLabels" $ | nindent 6 }} - type: {{ $v.type }} - ports: - - name: {{ template "papyrus.name" $ }}-port - protocol: "{{ $v.protocol }}" - port: {{ $v.port }} - targetPort: {{ $v.port }} -{{- end }} -{{- end }} diff --git a/deployments/helm/values.yaml b/deployments/helm/values.yaml index bad103541b..66b4a91b48 100644 --- a/deployments/helm/values.yaml +++ b/deployments/helm/values.yaml @@ -15,6 +15,35 @@ starknet: preset: mainnet.json additionalHeaders: # optional addtional headers for SN communication +p2p: + enabled: true + # Set to true if node act as bootstrap server + bootstrap: false + # General config + config: + # Optional - The node self port to listen | default "10000" + networkTcpPort: + # Optional - The node data path | default "data" + storageDbConfigPathPrefix: + # Optional - network.#is_none flag | default "false" + networkIsNone: + # 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 image: @@ -22,10 +51,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: @@ -34,21 +70,26 @@ 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: From eceb7ec557691838d2c5dc56d1defad38164fe90 Mon Sep 17 00:00:00 2001 From: Idan Shamam Date: Wed, 10 Jul 2024 10:16:24 +0300 Subject: [PATCH 2/4] fix(helm): removed default values from templates --- deployments/helm/templates/deployment.yaml | 12 ++++++------ deployments/helm/values.yaml | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/deployments/helm/templates/deployment.yaml b/deployments/helm/templates/deployment.yaml index 8cdd36ff29..bb55b3a044 100644 --- a/deployments/helm/templates/deployment.yaml +++ b/deployments/helm/templates/deployment.yaml @@ -64,7 +64,7 @@ spec: {{- if not .Values.backup.enabled }} {{- with .Values.deployment.env }} env: - {{- toYaml . | nindent 12 }} + {{- toYaml . | nindent 10 }} {{- end }} args: - --config_file @@ -73,14 +73,14 @@ spec: - {{ .Values.base_layer_node_url }} {{- if .Values.p2p.enabled }} - --network.tcp_port - - {{ default "10000" .Values.p2p.config.networkTcpPort | quote }} + - {{ .Values.p2p.config.networkTcpPort | quote }} - --storage.db_config.path_prefix - - {{ default "data" .Values.p2p.config.storageDbConfigPathPrefix | quote }} + - {{ .Values.p2p.config.storageDbConfigPathPrefix | quote }} - --network.#is_none - - {{ default false .Values.p2p.config.networkIsNone | quote }} + - {{ .Values.p2p.config.networkIsNone | quote }} {{- if not .Values.p2p.bootstrap }} - --network.bootstrap_peer_multiaddr.#is_none - - {{ default false .Values.p2p.nodeConfig.bootstrapServer.multiaddrIsNone | quote }} + - {{ .Values.p2p.nodeConfig.bootstrapServer.multiaddrIsNone | quote }} - --network.bootstrap_peer_multiaddr - {{ include "p2p.bootstrapPeerMultiaddr" . | quote }} {{- end}} @@ -103,7 +103,7 @@ spec: name: monitoring {{- end }} {{- if .Values.p2p.enabled }} - - containerPort: {{ default 10000 .Values.p2p.config.networkTcpPort }} + - containerPort: {{ .Values.p2p.config.networkTcpPort }} name: p2p {{- end }} volumeMounts: diff --git a/deployments/helm/values.yaml b/deployments/helm/values.yaml index 66b4a91b48..13b22d042e 100644 --- a/deployments/helm/values.yaml +++ b/deployments/helm/values.yaml @@ -13,7 +13,6 @@ 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: true @@ -21,12 +20,12 @@ p2p: bootstrap: false # General config config: - # Optional - The node self port to listen | default "10000" - networkTcpPort: - # Optional - The node data path | default "data" - storageDbConfigPathPrefix: - # Optional - network.#is_none flag | default "false" - networkIsNone: + # 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: From 20f46c7d60859583afdcae1a42b238b802cc087d Mon Sep 17 00:00:00 2001 From: Idan Shamam Date: Tue, 16 Jul 2024 12:18:03 +0300 Subject: [PATCH 3/4] fix(helm): added required mandatory fake values for helm install ci test to pass --- deployments/helm/values.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployments/helm/values.yaml b/deployments/helm/values.yaml index 13b22d042e..f18ff614e5 100644 --- a/deployments/helm/values.yaml +++ b/deployments/helm/values.yaml @@ -8,14 +8,14 @@ node: concurrentFgRequests: 50 # Ethereum node URL. A value for this variable is mandatory. -base_layer_node_url: +base_layer_node_url: https://base_url.example.com starknet: # possible values: "mainnet.json, sepolia_testnet" and "sepolia_integration". preset: mainnet.json p2p: - enabled: true + enabled: false # Set to true if node act as bootstrap server bootstrap: false # General config @@ -93,7 +93,7 @@ service: # Persistent volume claim variables for a papyrus pod. pvc: # Recommended size is at least 512Gi. - size: + size: 1Gi # 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 From 4320c60d462fb390f38aa25103f78ce123de14af Mon Sep 17 00:00:00 2001 From: Idan Shamam Date: Wed, 17 Jul 2024 13:49:36 +0300 Subject: [PATCH 4/4] fix(helm): changed default values --- deployments/helm/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/helm/values.yaml b/deployments/helm/values.yaml index f18ff614e5..a692b838c3 100644 --- a/deployments/helm/values.yaml +++ b/deployments/helm/values.yaml @@ -8,7 +8,7 @@ node: concurrentFgRequests: 50 # Ethereum node URL. A value for this variable is mandatory. -base_layer_node_url: https://base_url.example.com +base_layer_node_url: starknet: # possible values: "mainnet.json, sepolia_testnet" and "sepolia_integration". @@ -93,7 +93,7 @@ service: # Persistent volume claim variables for a papyrus pod. pvc: # Recommended size is at least 512Gi. - size: 1Gi + 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