From 9da7ec16b7b0243e962bb967781f400ea38a618e Mon Sep 17 00:00:00 2001 From: Nick Zenchik Date: Wed, 5 Jun 2024 10:46:01 +0400 Subject: [PATCH] [rpc-node] Adding consensus layer --- charts/rpc-node/Chart.yaml | 2 +- .../rpc-node/templates/consensus-secret.yaml | 13 ++ .../rpc-node/templates/consensus-service.yaml | 41 ++++++ .../templates/consensus-stateful-set.yaml | 129 +++++++++++++++++ .../templates/execution-stateful-set.yaml | 2 +- charts/rpc-node/values.yaml | 130 ++++++++++++++++-- 6 files changed, 305 insertions(+), 12 deletions(-) create mode 100644 charts/rpc-node/templates/consensus-secret.yaml create mode 100644 charts/rpc-node/templates/consensus-service.yaml create mode 100644 charts/rpc-node/templates/consensus-stateful-set.yaml diff --git a/charts/rpc-node/Chart.yaml b/charts/rpc-node/Chart.yaml index d52d427..af850ae 100644 --- a/charts/rpc-node/Chart.yaml +++ b/charts/rpc-node/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.2.0 +version: 0.3.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/rpc-node/templates/consensus-secret.yaml b/charts/rpc-node/templates/consensus-secret.yaml new file mode 100644 index 0000000..d352ba5 --- /dev/null +++ b/charts/rpc-node/templates/consensus-secret.yaml @@ -0,0 +1,13 @@ +{{- if and .Values.consensus.enabled .Values.consensus.envFromSecret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "rpc-node.fullname" . }}-consensus-env + labels: + {{- include "rpc-node.labels" . | nindent 4 }} +type: Opaque +data: +{{- range $key, $value := .Values.consensus.envFromSecret }} + {{ $key }}: {{ $value | b64enc }} +{{- end }} +{{- end }} diff --git a/charts/rpc-node/templates/consensus-service.yaml b/charts/rpc-node/templates/consensus-service.yaml new file mode 100644 index 0000000..f1768b5 --- /dev/null +++ b/charts/rpc-node/templates/consensus-service.yaml @@ -0,0 +1,41 @@ +{{- if .Values.consensus.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "rpc-node.fullname" . }}-consensus-cluster + labels: + {{- include "rpc-node.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + {{- range .Values.consensus.service.cluster.ports }} + - port: {{ .port }} + targetPort: {{ .port }} + protocol: {{ .protocol }} + name: {{ .name }} + {{- end }} + selector: + app: {{ .Release.Name }}-consensus + {{- include "rpc-node.selectorLabels" . | nindent 4 }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "rpc-node.fullname" . }}-consensus-node + labels: + {{- include "rpc-node.labels" . | nindent 4 }} +spec: + type: NodePort + externalTrafficPolicy: Local + ports: + {{- range .Values.consensus.service.node.ports }} + - port: {{ .port }} + targetPort: {{ .port }} + protocol: {{ .protocol }} + name: {{ .name }} + nodePort: {{ .port }} + {{- end }} + selector: + app: {{ .Release.Name }}-consensus + {{- include "rpc-node.selectorLabels" . | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/charts/rpc-node/templates/consensus-stateful-set.yaml b/charts/rpc-node/templates/consensus-stateful-set.yaml new file mode 100644 index 0000000..3d45ff6 --- /dev/null +++ b/charts/rpc-node/templates/consensus-stateful-set.yaml @@ -0,0 +1,129 @@ +{{- if .Values.consensus.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "rpc-node.fullname" . }}-consensus + labels: + app: {{ .Release.Name }}-consensus + {{- include "rpc-node.labels" . | nindent 4 }} +spec: + replicas: 1 + serviceName: {{ include "rpc-node.fullname" . }}-consensus + selector: + matchLabels: + app: {{ .Release.Name }}-consensus + {{- include "rpc-node.selectorLabels" . | nindent 6 }} + updateStrategy: + type: {{ .Values.updateStrategy }} + {{- if .Values.consensus.persistence.enabled }} + volumeClaimTemplates: + - metadata: + name: consensus-data + spec: + accessModes: + {{- range .Values.consensus.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.consensus.persistence.size | quote }} + {{- if .Values.consensus.persistence.storageClass }} + {{- if (eq "-" .Values.consensus.persistence.storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: "{{ .Values.consensus.persistence.storageClass }}" + {{- end }} + {{- end }} + {{- end }} + template: + metadata: + {{- with .Values.consensus.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + app: {{ .Release.Name }}-consensus + {{- include "rpc-node.labels" . | nindent 8 }} + {{- with .Values.consensus.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "rpc-node.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.consensus.podSecurityContext | nindent 8 }} + containers: + - name: consensus + securityContext: + {{- toYaml .Values.consensus.securityContext | nindent 12 }} + image: "{{ .Values.consensus.image.repository }}:{{ .Values.consensus.image.tag }}" + imagePullPolicy: {{ .Values.consensus.image.pullPolicy }} + {{- with .Values.consensus.command }} + command: {{ . | toYaml | nindent 12 }} + {{- end }} + {{- with (concat .Values.consensus.args .Values.consensus.extraArgs) }} + args: {{ toYaml . | nindent 12 }} + {{- end }} + {{- if .Values.consensus.env }} + env: + {{- range $key, $value := .Values.consensus.env }} + - name: {{ $key }} + value: {{ $value | quote }} + {{- end }} + {{- end }} + {{- if .Values.consensus.envFromSecret }} + envFrom: + - secretRef: + name: {{ include "rpc-node.fullname" . }}-consensus-env + {{- range .Values.consensus.envFrom }} + - {{ toYaml . | nindent 12 | trim }} + {{- end }} + {{- end }} + ports: + {{- range .Values.consensus.service.cluster.ports }} + - name: {{ .name }} + containerPort: {{ .port }} + protocol: {{ .protocol }} + {{- end }} + {{- range .Values.consensus.service.node.ports }} + - name: {{ .name }} + containerPort: {{ .port }} + protocol: {{ .protocol }} + {{- end }} + livenessProbe: + {{- toYaml .Values.consensus.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.consensus.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.consensus.resources | nindent 12 }} + {{- if or .Values.consensus.persistence.enabled .Values.volumeMounts }} + volumeMounts: + {{- if .Values.consensus.persistence.enabled }} + - name: consensus-data + mountPath: /data + {{- end }} + {{- with .Values.consensus.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + {{- end }} + {{- with .Values.consensus.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + terminationGracePeriodSeconds: 300 + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/rpc-node/templates/execution-stateful-set.yaml b/charts/rpc-node/templates/execution-stateful-set.yaml index c1e8a9e..ba5efdd 100644 --- a/charts/rpc-node/templates/execution-stateful-set.yaml +++ b/charts/rpc-node/templates/execution-stateful-set.yaml @@ -63,7 +63,7 @@ spec: {{- with .Values.execution.command }} command: {{ . | toYaml | nindent 12 }} {{- end }} - {{- with .Values.execution.args }} + {{- with (concat .Values.execution.args .Values.execution.extraArgs) }} args: {{ toYaml . | nindent 12 }} {{- end }} {{- if .Values.execution.env }} diff --git a/charts/rpc-node/values.yaml b/charts/rpc-node/values.yaml index 355e1c0..63743da 100644 --- a/charts/rpc-node/values.yaml +++ b/charts/rpc-node/values.yaml @@ -89,19 +89,20 @@ execution: # hosts: # - chart-example.local command: - args: - - --http - - --http.addr="0.0.0.0" - - --http.port="8545" - - --http.compression - - --http.vhosts="*" - - --http.corsdomain="*" - - --http.api="eth,debug,net,trace,txpool,web3,erigon" - - --ws - - --ws.compression + args: [] + #- --http + #- --http.addr="0.0.0.0" + #- --http.port="8545" + #- --http.compression + #- --http.vhosts="*" + #- --http.corsdomain="*" + #- --http.api="eth,debug,net,trace,txpool,web3,erigon" + #- --ws + #- --ws.compression #- --metrics #- --metrics.addr=0.0.0.0 #- --metrics.port=6060 + extraArgs: [] env: [] # NAME: VALUE @@ -152,3 +153,112 @@ execution: # - name: foo # mountPath: "/etc/foo" # readOnly: true + +consensus: + enabled: false + image: + repository: sigp/lighthouse + pullPolicy: IfNotPresent + tag: "latest" + + podAnnotations: {} + podLabels: {} + + podSecurityContext: {} + # fsGroup: 2000 + + persistence: + enabled: false + # storageClass: "-" + accessModes: + - ReadWriteOnce + size: 10Gi + annotations: {} + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + cluster: + ports: + - name: rpc + port: 5052 + protocol: TCP + node: + ports: + - name: p2p-tcp + port: 9909 + protocol: TCP + - name: p2p-udp + port: 9909 + protocol: UDP + + command: "lighthouse bn" + args: [] + #- --network + #- mainnet + #- --checkpoint-sync-url + #- https://mainnet.checkpoint.sigp.io + #- --execution-endpoint + #- http://{{ include "rpc-node.fullname" . }}-execution-cluster:8551 + #- --execution-jwt + #- /jwtsecret + #- --disable-deposit-contract-sync + #- --listen-address + #- 0.0.0.0 + #- --port + #- 9909 + #- --http + #- --http-address + #- 0.0.0.0 + extraArgs: [] + + env: [] + # NAME: VALUE + # This will create a Secret with the specified data + envFromSecret: [] + # NAME: VALUE + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + livenessProbe: + httpGet: + path: / + port: rpc + initialDelaySeconds: 60 + periodSeconds: 30 + timeoutSeconds: 15 + readinessProbe: + httpGet: + path: / + port: rpc + initialDelaySeconds: 30 + periodSeconds: 30 + timeoutSeconds: 15 + + # Additional volumes on the output Deployment definition. + volumes: [] + # - name: foo + # secret: + # secretName: mysecret + # optional: false + + # Additional volumeMounts on the output Deployment definition. + volumeMounts: [] + # - name: foo + # mountPath: "/etc/foo" + # readOnly: true