From 82e915568120875e0e3052d958e9b70d7ab45df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Tue, 28 May 2024 21:03:31 +0200 Subject: [PATCH 01/26] make secrets optional --- charts/charon/templates/deployment.yaml | 2 ++ charts/charon/values.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index d4d1fd8..c08c129 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -105,6 +105,7 @@ spec: {{- if .Values.extraVolumes -}} {{ toYaml .Values.extraVolumes | nindent 8 }} {{- end }} + {{- if .Values.secrets.enabled -}} - name: charon-enr-private-key projected: sources: @@ -115,4 +116,5 @@ spec: sources: - secret: name: {{ .Values.secrets.clusterlock }} + {{- end }} diff --git a/charts/charon/values.yaml b/charts/charon/values.yaml index 571a428..e8eac16 100644 --- a/charts/charon/values.yaml +++ b/charts/charon/values.yaml @@ -228,6 +228,7 @@ config: # -- Kubernetes secrets names secrets: + enabled: true # -- validators keys validatorKeys: "validator-keys" # -- charon enr private key From 3d01aef63ee8519400bd3a7af4c544f884d5f0fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Tue, 28 May 2024 21:13:45 +0200 Subject: [PATCH 02/26] add missing volumes --- charts/charon/templates/deployment.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index c08c129..4bc8d91 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -116,5 +116,10 @@ spec: sources: - secret: name: {{ .Values.secrets.clusterlock }} + {{- else }} + - name: cluster-lock + emptyDir: {} + - name: charon-enr-private-key + emptyDir: {} {{- end }} From de10abfd9b9a7579291c76ad60c87e83e278c615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Tue, 28 May 2024 22:21:25 +0200 Subject: [PATCH 03/26] add udp port for p2p --- charts/charon/templates/deployment.yaml | 3 +++ charts/charon/templates/service.yaml | 4 ++++ charts/charon/values.yaml | 2 ++ 3 files changed, 9 insertions(+) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index 4bc8d91..aa5fe3c 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -80,6 +80,9 @@ spec: - containerPort: {{ .Values.p2pPort }} name: p2p-tcp protocol: TCP + - containerPort: {{ .Values.p2pPortUDP }} + name: p2p-udp + protocol: UDP - containerPort: {{ .Values.monitoringPort }} name: monitoring protocol: TCP diff --git a/charts/charon/templates/service.yaml b/charts/charon/templates/service.yaml index b6ad6b5..05aa06e 100644 --- a/charts/charon/templates/service.yaml +++ b/charts/charon/templates/service.yaml @@ -15,6 +15,10 @@ spec: targetPort: p2p-tcp protocol: TCP name: p2p-tcp + - port: {{ .Values.p2pPortUDP }} + targetPort: p2p-udp + protocol: UDP + name: p2p-udp - port: {{ .Values.monitoringPort }} targetPort: monitoring protocol: TCP diff --git a/charts/charon/values.yaml b/charts/charon/values.yaml index e8eac16..683c404 100644 --- a/charts/charon/values.yaml +++ b/charts/charon/values.yaml @@ -139,6 +139,8 @@ p2pPort: 3610 # -- Monitoring Port monitoringPort: 3620 +p2pPortUDP: 3630 + # -- Jaeger Port jaegerPort: 6831 From 6c589dfa7ffa6a0ebf7f85879ffa63013e12dfa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Thu, 30 May 2024 17:59:54 +0200 Subject: [PATCH 04/26] optional readiness and liveness --- charts/charon/templates/deployment.yaml | 4 ++++ charts/charon/values.yaml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index aa5fe3c..da2501d 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -69,10 +69,14 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.livenessProbe.enabled }} livenessProbe: {{- toYaml .Values.livenessProbe | nindent 12 }} + {{- end }} + {{- if .Values.readinessProbe.enabled }} readinessProbe: {{- toYaml .Values.readinessProbe | nindent 12 }} + {{- end }} ports: - containerPort: {{ .Values.httpPort }} name: validator-api diff --git a/charts/charon/values.yaml b/charts/charon/values.yaml index 683c404..36ea92f 100644 --- a/charts/charon/values.yaml +++ b/charts/charon/values.yaml @@ -285,6 +285,7 @@ serviceMonitor: # -- Configure liveness probes livenessProbe: + enabled: true initialDelaySeconds: 60 periodSeconds: 120 httpGet: @@ -292,6 +293,7 @@ livenessProbe: port: monitoring # -- Configure readiness probes readinessProbe: + enabled: true initialDelaySeconds: 10 periodSeconds: 10 httpGet: From daee5e76524dbfec9c578124ede9efc542cd0597 Mon Sep 17 00:00:00 2001 From: Denis Policastro Date: Mon, 24 Jun 2024 12:35:21 -0300 Subject: [PATCH 05/26] Update servicemonitor.yaml --- charts/charon/templates/servicemonitor.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/charon/templates/servicemonitor.yaml b/charts/charon/templates/servicemonitor.yaml index c7d3a34..b3349c0 100644 --- a/charts/charon/templates/servicemonitor.yaml +++ b/charts/charon/templates/servicemonitor.yaml @@ -22,7 +22,7 @@ spec: scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} {{- end }} honorLabels: true - port: metrics + port: monitoring path: {{ .Values.serviceMonitor.path }} scheme: {{ .Values.serviceMonitor.scheme }} {{- if .Values.serviceMonitor.tlsConfig }} From 1285f2c720e3aca5b693965e238a05c15b993487 Mon Sep 17 00:00:00 2001 From: Denis Policastro Date: Mon, 1 Jul 2024 12:31:59 -0300 Subject: [PATCH 06/26] feat: prefix prometheus resources with release name --- charts/charon/templates/prometheus-configmap.yaml | 2 +- charts/charon/templates/prometheus-deployment.yaml | 10 +++++----- charts/charon/templates/prometheus-service.yaml | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/charts/charon/templates/prometheus-configmap.yaml b/charts/charon/templates/prometheus-configmap.yaml index fb269d1..1992c0b 100644 --- a/charts/charon/templates/prometheus-configmap.yaml +++ b/charts/charon/templates/prometheus-configmap.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: prometheus + name: {{ include "release.name" . }}-prometheus data: prometheus.yaml: | global: diff --git a/charts/charon/templates/prometheus-deployment.yaml b/charts/charon/templates/prometheus-deployment.yaml index bf6fefe..732cf6f 100644 --- a/charts/charon/templates/prometheus-deployment.yaml +++ b/charts/charon/templates/prometheus-deployment.yaml @@ -3,17 +3,17 @@ apiVersion: apps/v1 kind: Deployment metadata: labels: - app: prometheus - name: prometheus + app: {{ include "release.name" . }}-prometheus + name: {{ include "release.name" . }}-prometheus spec: replicas: 1 selector: matchLabels: - app: prometheus + app: {{ include "release.name" . }}-prometheus template: metadata: labels: - app: prometheus + app: {{ include "release.name" . }}-prometheus spec: containers: - args: @@ -34,4 +34,4 @@ spec: defaultMode: 420 name: prometheus name: prometheus -{{- end }} \ No newline at end of file +{{- end }} diff --git a/charts/charon/templates/prometheus-service.yaml b/charts/charon/templates/prometheus-service.yaml index 7f26ed4..a9c9aee 100644 --- a/charts/charon/templates/prometheus-service.yaml +++ b/charts/charon/templates/prometheus-service.yaml @@ -2,14 +2,14 @@ apiVersion: v1 kind: Service metadata: - name: prometheus + name: {{ include "release.name" . }}-prometheus spec: ports: - port: 9090 protocol: TCP targetPort: 9090 selector: - app: prometheus + app: {{ include "release.name" . }}-prometheus sessionAffinity: None type: ClusterIP {{- end }} From 532bbfef8a7216eb333bdd1e6ac981025f12ad1c Mon Sep 17 00:00:00 2001 From: Denis Policastro Date: Mon, 1 Jul 2024 12:32:43 -0300 Subject: [PATCH 07/26] feat: add resources field to Prometheus --- charts/charon/templates/prometheus-deployment.yaml | 4 ++++ charts/charon/values.yaml | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/charts/charon/templates/prometheus-deployment.yaml b/charts/charon/templates/prometheus-deployment.yaml index 732cf6f..acb3aef 100644 --- a/charts/charon/templates/prometheus-deployment.yaml +++ b/charts/charon/templates/prometheus-deployment.yaml @@ -27,6 +27,10 @@ spec: - mountPath: /etc/prometheus/prometheus.yaml name: prometheus subPath: prometheus.yaml + {{- with .Values.centralMonitoring.resources }} + resources: + {{- toYaml . | nindent 10 }} + {{- end }} securityContext: runAsUser: 0 volumes: diff --git a/charts/charon/values.yaml b/charts/charon/values.yaml index 36ea92f..ac16d6e 100644 --- a/charts/charon/values.yaml +++ b/charts/charon/values.yaml @@ -308,4 +308,11 @@ centralMonitoring: promEndpoint: "https://vm.monitoring.gcp.obol.tech/write" # -- The authentication token to the central prometheus token: "" - \ No newline at end of file + resources: + {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi From c1e0387b8de3dcece1fed770e10c92591e99a59d Mon Sep 17 00:00:00 2001 From: Denis Policastro Date: Mon, 1 Jul 2024 12:33:13 -0300 Subject: [PATCH 08/26] fix: remove dash condition --- charts/charon/templates/deployment.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index da2501d..1dd636f 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -112,7 +112,7 @@ spec: {{- if .Values.extraVolumes -}} {{ toYaml .Values.extraVolumes | nindent 8 }} {{- end }} - {{- if .Values.secrets.enabled -}} + {{- if .Values.secrets.enabled }} - name: charon-enr-private-key projected: sources: @@ -129,4 +129,3 @@ spec: - name: charon-enr-private-key emptyDir: {} {{- end }} - From d34bbb20486a8da709ba6e606b45073b5e535a5d Mon Sep 17 00:00:00 2001 From: Denis Policastro Date: Mon, 1 Jul 2024 13:10:42 -0300 Subject: [PATCH 09/26] fix: config map reference --- charts/charon/templates/prometheus-deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/charon/templates/prometheus-deployment.yaml b/charts/charon/templates/prometheus-deployment.yaml index acb3aef..51c32cd 100644 --- a/charts/charon/templates/prometheus-deployment.yaml +++ b/charts/charon/templates/prometheus-deployment.yaml @@ -36,6 +36,6 @@ spec: volumes: - configMap: defaultMode: 420 - name: prometheus + name: {{ include "release.name" . }}-prometheus name: prometheus {{- end }} From e4d4062bc4d38599efedd1ed67f915e6e3715577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Fri, 26 Jul 2024 14:06:56 +0200 Subject: [PATCH 10/26] add separate p2p service to allow NodePort exposure --- charts/charon/templates/configmap.yaml | 2 +- charts/charon/templates/deployment.yaml | 4 +-- charts/charon/templates/service-p2p.yaml | 39 ++++++++++++++++++++++++ charts/charon/templates/service.yaml | 8 ----- charts/charon/values.yaml | 19 +++++++++++- 5 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 charts/charon/templates/service-p2p.yaml diff --git a/charts/charon/templates/configmap.yaml b/charts/charon/templates/configmap.yaml index 158dccf..155882c 100644 --- a/charts/charon/templates/configmap.yaml +++ b/charts/charon/templates/configmap.yaml @@ -62,7 +62,7 @@ data: CHARON_P2P_RELAYS: {{ .Values.config.p2pRelays | quote }} {{- end }} {{- if .Values.config.p2pTcpAddress }} - CHARON_P2P_TCP_ADDRESS: {{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort }} + CHARON_P2P_TCP_ADDRESS: {{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.port }} {{- end }} {{- if .Values.config.privateKeyFile }} CHARON_PRIVATE_KEY_FILE: {{ .Values.config.privateKeyFile | quote }} diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index 1dd636f..dcf29cf 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -81,10 +81,10 @@ spec: - containerPort: {{ .Values.httpPort }} name: validator-api protocol: TCP - - containerPort: {{ .Values.p2pPort }} + - containerPort: {{ .Values.p2pPort.port }} name: p2p-tcp protocol: TCP - - containerPort: {{ .Values.p2pPortUDP }} + - containerPort: {{ .Values.p2pPort.port }} name: p2p-udp protocol: UDP - containerPort: {{ .Values.monitoringPort }} diff --git a/charts/charon/templates/service-p2p.yaml b/charts/charon/templates/service-p2p.yaml new file mode 100644 index 0000000..9bcd779 --- /dev/null +++ b/charts/charon/templates/service-p2p.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "release.name" . }}-p2p + labels: + {{- include "charon.labels" . | nindent 4 }} + type: p2p + {{- with .Values.p2pPort.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ $.Values.p2pPort.type }} + externalTrafficPolicy: Local + ports: + {{- if eq .Values.p2pPort.type "NodePort" }} + - name: p2p-tcp + port: {{ .Values.p2pPort.port }} + protocol: TCP + targetPort: {{ .Values.p2pPort.nodePort }} + nodePort: {{ .Values.p2pPort.nodePort }} + - name: p2p-udp + port: {{ .Values.p2pPort.port }} + protocol: UDP + targetPort: {{ .Values.p2pPort.nodePort }} + nodePort: {{ .Values.p2pPort.nodePort }} + {{- else }} + - port: {{ .Values.p2pPort.port }} + targetPort: p2p-tcp + protocol: TCP + name: p2p-tcp + - port: {{ .Values.p2pPort.port}} + targetPort: p2p-udp + protocol: UDP + name: p2p-udp + {{- end }} + selector: + {{- include "charon.selectorLabels" . | nindent 4 }} \ No newline at end of file diff --git a/charts/charon/templates/service.yaml b/charts/charon/templates/service.yaml index 05aa06e..b9ee758 100644 --- a/charts/charon/templates/service.yaml +++ b/charts/charon/templates/service.yaml @@ -11,14 +11,6 @@ spec: targetPort: validator-api protocol: TCP name: validator-api - - port: {{ .Values.p2pPort }} - targetPort: p2p-tcp - protocol: TCP - name: p2p-tcp - - port: {{ .Values.p2pPortUDP }} - targetPort: p2p-udp - protocol: UDP - name: p2p-udp - port: {{ .Values.monitoringPort }} targetPort: monitoring protocol: TCP diff --git a/charts/charon/values.yaml b/charts/charon/values.yaml index ac16d6e..063fac2 100644 --- a/charts/charon/values.yaml +++ b/charts/charon/values.yaml @@ -139,7 +139,24 @@ p2pPort: 3610 # -- Monitoring Port monitoringPort: 3620 -p2pPortUDP: 3630 +## When p2pNodePort is enabled, your P2P port will be exposed via service type NodePort. +## This will generate a service for each replica, with a port binding via NodePort. +## This is useful if you want to expose and announce your node to the Internet. +## +p2pNodePort: + ## @param p2pNodePort.enabled Expose P2P port via NodePort + ## + enabled: false + ## @param p2pNodePort.annotations + ## + annotations: {} + ## @param p2pNodePort.type + ## Options: NodePort, LoadBalancer + type: NodePort + ## @param p2pNodePort.startAt The ports allocation will start from this value + ## + port: 32000 + # -- Jaeger Port jaegerPort: 6831 From 5cec57179272dbb43a83f7d9f791d73e7e2d97ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Fri, 26 Jul 2024 14:08:14 +0200 Subject: [PATCH 11/26] remove redundant value --- charts/charon/values.yaml | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/charts/charon/values.yaml b/charts/charon/values.yaml index 063fac2..a9b1b64 100644 --- a/charts/charon/values.yaml +++ b/charts/charon/values.yaml @@ -133,29 +133,26 @@ podDisruptionBudget: # -- HTTP Port httpPort: 3600 -# -- Engine Port (Auth Port) -p2pPort: 3610 - # -- Monitoring Port monitoringPort: 3620 -## When p2pNodePort is enabled, your P2P port will be exposed via service type NodePort. -## This will generate a service for each replica, with a port binding via NodePort. +## When p2pPort.type is NodePort, your P2P port will be exposed via service type NodePort. +## This will generate a service with a port binding via NodePort. ## This is useful if you want to expose and announce your node to the Internet. ## -p2pNodePort: - ## @param p2pNodePort.enabled Expose P2P port via NodePort - ## - enabled: false - ## @param p2pNodePort.annotations +p2pPort: + ## @param p2pPort.annotations ## annotations: {} - ## @param p2pNodePort.type - ## Options: NodePort, LoadBalancer + ## @param p2pPort.type + ## Options: NodePort, LoadBalancer, ClusterIP type: NodePort ## @param p2pNodePort.startAt The ports allocation will start from this value ## - port: 32000 + nodePort: 32000 + ## @param p2pPort.port The default P2P port for charon service + ## + port: 3610 # -- Jaeger Port From 1f6e37faece42dc8383d891fea6679b6beced390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 19:31:14 +0200 Subject: [PATCH 12/26] adding nodePort init stuff --- charts/charon/templates/configmap.yaml | 25 ++++++++++-- charts/charon/templates/deployment.yaml | 52 +++++++++++++++++++++++-- charts/charon/values.yaml | 5 +++ 3 files changed, 76 insertions(+), 6 deletions(-) diff --git a/charts/charon/templates/configmap.yaml b/charts/charon/templates/configmap.yaml index 155882c..0c8c78a 100644 --- a/charts/charon/templates/configmap.yaml +++ b/charts/charon/templates/configmap.yaml @@ -61,9 +61,6 @@ data: {{- if .Values.config.p2pRelays }} CHARON_P2P_RELAYS: {{ .Values.config.p2pRelays | quote }} {{- end }} - {{- if .Values.config.p2pTcpAddress }} - CHARON_P2P_TCP_ADDRESS: {{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.port }} - {{- end }} {{- if .Values.config.privateKeyFile }} CHARON_PRIVATE_KEY_FILE: {{ .Values.config.privateKeyFile | quote }} {{- end }} @@ -82,3 +79,25 @@ data: {{- if .Values.config.validatorApiAddress }} CHARON_VALIDATOR_API_ADDRESS: {{ .Values.config.validatorApiAddress }}:{{ .Values.httpPort }} {{- end }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "release.name" . }}-init + labels: + {{- include "charon.labels" . | nindent 4 }} +data: + init.sh: | + #!/bin/sh + echo "Namespace: ${POD_NAMESPACE} Pod: ${POD_NAME}"; + {{- if eq .Values.p2pNodePort.type "LoadBalancer" }} + until [ -n "$(kubectl -n ${POD_NAMESPACE} get svc/${POD_NAME} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" ]; do echo "Waiting for load balancer to get an IP" && sleep 10; done; + export EXTERNAL_PORT=$(kubectl -n ${POD_NAMESPACE} get services -l "type in (p2p)" -o jsonpath='{.items[0].spec.ports[0].nodePort}'); + export EXTERNAL_IP=$(kubectl -n ${POD_NAMESPACE} get svc/${POD_NAME} -o jsonpath='{.status.loadBalancer.ingress[0].ip}'); + {{- else if eq .Values.p2pPort.type "NodePort" }} + export EXTERNAL_PORT=$(kubectl get services -l "type in (p2p)" -o jsonpath='{.items[0].spec.ports[0].nodePort}'); + export EXTERNAL_IP=$(kubectl get nodes "${NODE_NAME}" -o jsonpath='{.status.addresses[?(@.type=="ExternalIP")].address}'); + {{- end }} + echo "EXTERNAL_PORT=$EXTERNAL_PORT" > /env/init-nodeport; + echo "EXTERNAL_IP=$EXTERNAL_IP" >> /env/init-nodeport; + cat /env/init-nodeport; diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index dcf29cf..19ca00d 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -48,11 +48,50 @@ spec: {{- if .Values.initContainers }} {{- tpl (toYaml .Values.initContainers | nindent 8) $ }} {{- end }} + {{- if eq .Values.p2pPort.type "NodePort" }} + - name: init + image: "{{ .Values.initImage.repository }}:{{ .Values.initImage.tag }}" + imagePullPolicy: {{ .Values.initImage.pullPolicy }} + securityContext: + runAsNonRoot: false + runAsUser: 0 + env: + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + command: ['/bin/sh', '/scripts/init.sh'] + volumeMounts: + - name: env-nodeport + mountPath: /env + - name: scripts-init + mountPath: /scripts + {{- end }} containers: - - args: - - run command: - - /usr/local/bin/charon + - sh + - -ac + - > + . /env/init-nodeport + exec /usr/local/bin/charon + run + {{- if or (eq .Values.p2pPort.type "NodePort") (eq .Values.p2pPort.type "LoadBalancer") }} + --p2p-tcp-address=$EXTERNAL_IP:$EXTERNAL_PORT + {{- else }} + --p2p-tcp-address=$POD_IP:{{ .Values.p2pPort.port }} + {{- end }} env: - name: KUBERNETES_CLUSTER_DOMAIN value: {{ .Values.kubernetesClusterDomain }} @@ -98,6 +137,8 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} volumeMounts: + - name: env-nodeport + mountPath: /env {{- if .Values.extraVolumeMounts -}} {{ toYaml .Values.extraVolumeMounts | nindent 12 }} {{- end }} @@ -112,6 +153,11 @@ spec: {{- if .Values.extraVolumes -}} {{ toYaml .Values.extraVolumes | nindent 8 }} {{- end }} + - name: env-nodeport + emptyDir: {} + - name: scripts-init + configMap: + name: {{ include "release.name" . }}-init {{- if .Values.secrets.enabled }} - name: charon-enr-private-key projected: diff --git a/charts/charon/values.yaml b/charts/charon/values.yaml index a9b1b64..f5d6430 100644 --- a/charts/charon/values.yaml +++ b/charts/charon/values.yaml @@ -8,6 +8,11 @@ image: pullPolicy: IfNotPresent tag: v0.19.1 +initImage: + repository: "bitnami/kubectl" + tag: "1.30.3" + pullPolicy: IfNotPresent + # -- Credentials to fetch images from private registry ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ imagePullSecrets: [] From 2ec0e3b7464dc052e6283fa2428b603793d3ea53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 19:35:39 +0200 Subject: [PATCH 13/26] fix null ref --- charts/charon/templates/configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/charon/templates/configmap.yaml b/charts/charon/templates/configmap.yaml index 0c8c78a..b50f2a5 100644 --- a/charts/charon/templates/configmap.yaml +++ b/charts/charon/templates/configmap.yaml @@ -90,7 +90,7 @@ data: init.sh: | #!/bin/sh echo "Namespace: ${POD_NAMESPACE} Pod: ${POD_NAME}"; - {{- if eq .Values.p2pNodePort.type "LoadBalancer" }} + {{- if eq .Values.p2pPort.type "LoadBalancer" }} until [ -n "$(kubectl -n ${POD_NAMESPACE} get svc/${POD_NAME} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" ]; do echo "Waiting for load balancer to get an IP" && sleep 10; done; export EXTERNAL_PORT=$(kubectl -n ${POD_NAMESPACE} get services -l "type in (p2p)" -o jsonpath='{.items[0].spec.ports[0].nodePort}'); export EXTERNAL_IP=$(kubectl -n ${POD_NAMESPACE} get svc/${POD_NAME} -o jsonpath='{.status.loadBalancer.ingress[0].ip}'); From 2b015f5e4d8e59335530912e6eb3919cf6080e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 19:39:26 +0200 Subject: [PATCH 14/26] fix yaml --- charts/charon/templates/deployment.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index 19ca00d..fec6a3b 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -48,7 +48,6 @@ spec: {{- if .Values.initContainers }} {{- tpl (toYaml .Values.initContainers | nindent 8) $ }} {{- end }} - {{- if eq .Values.p2pPort.type "NodePort" }} - name: init image: "{{ .Values.initImage.repository }}:{{ .Values.initImage.tag }}" imagePullPolicy: {{ .Values.initImage.pullPolicy }} @@ -78,19 +77,20 @@ spec: mountPath: /env - name: scripts-init mountPath: /scripts - {{- end }} containers: command: - sh - -ac - > + {{- if ne .Values.p2pPort.type "ClusterIP" }} . /env/init-nodeport + {{- end }} exec /usr/local/bin/charon run - {{- if or (eq .Values.p2pPort.type "NodePort") (eq .Values.p2pPort.type "LoadBalancer") }} - --p2p-tcp-address=$EXTERNAL_IP:$EXTERNAL_PORT - {{- else }} + {{- if eq .Values.p2pPort.type "ClusterIp" }} --p2p-tcp-address=$POD_IP:{{ .Values.p2pPort.port }} + {{- else }} + --p2p-tcp-address=$EXTERNAL_IP:$EXTERNAL_PORT {{- end }} env: - name: KUBERNETES_CLUSTER_DOMAIN From d90a4bd9db06315fd1f81a2ee73eb05d317fb109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 19:48:17 +0200 Subject: [PATCH 15/26] fix yaml --- charts/charon/templates/deployment.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index fec6a3b..cf36b33 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -78,6 +78,13 @@ spec: - name: scripts-init mountPath: /scripts containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- with .Values.containerSecurityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} command: - sh - -ac @@ -101,13 +108,6 @@ spec: envFrom: - configMapRef: name: {{ include "release.name" . }} - image: {{ .Values.image.repository }}:{{ .Values.image.tag }} - name: {{ .Chart.Name }} - {{- with .Values.containerSecurityContext }} - securityContext: - {{- toYaml . | nindent 12 }} - {{- end }} - imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.livenessProbe.enabled }} livenessProbe: {{- toYaml .Values.livenessProbe | nindent 12 }} From db9d9f29c3a870580adde8ba491d4f538b756f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 19:55:37 +0200 Subject: [PATCH 16/26] try to exec charon --- charts/charon/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index cf36b33..e602a4b 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -92,7 +92,7 @@ spec: {{- if ne .Values.p2pPort.type "ClusterIP" }} . /env/init-nodeport {{- end }} - exec /usr/local/bin/charon + exec charon run {{- if eq .Values.p2pPort.type "ClusterIp" }} --p2p-tcp-address=$POD_IP:{{ .Values.p2pPort.port }} From 6921a3f1ddc7244de7e3126ceb37565d0b53a998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 19:57:51 +0200 Subject: [PATCH 17/26] remove exec --- charts/charon/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index e602a4b..67b4b67 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -92,7 +92,7 @@ spec: {{- if ne .Values.p2pPort.type "ClusterIP" }} . /env/init-nodeport {{- end }} - exec charon + charon run {{- if eq .Values.p2pPort.type "ClusterIp" }} --p2p-tcp-address=$POD_IP:{{ .Values.p2pPort.port }} From adba1156fb9448fd2356c82f0e8ee1594acf1c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 20:04:53 +0200 Subject: [PATCH 18/26] try different approach --- charts/charon/templates/deployment.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index 67b4b67..c0434ce 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -86,19 +86,18 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} command: - - sh - - -ac - - > + - /bin/sh + - -c + - | {{- if ne .Values.p2pPort.type "ClusterIP" }} . /env/init-nodeport {{- end }} - charon - run - {{- if eq .Values.p2pPort.type "ClusterIp" }} + exec charon run \ + {{- if eq .Values.p2pPort.type "ClusterIP" }} --p2p-tcp-address=$POD_IP:{{ .Values.p2pPort.port }} - {{- else }} + {{- else }} --p2p-tcp-address=$EXTERNAL_IP:$EXTERNAL_PORT - {{- end }} + {{- end }} env: - name: KUBERNETES_CLUSTER_DOMAIN value: {{ .Values.kubernetesClusterDomain }} From 434eec7d299b7c3cd1d8634f52963bc708f1725b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 20:07:01 +0200 Subject: [PATCH 19/26] use hardcoded nodePort value --- charts/charon/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index c0434ce..64d6bcd 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -96,7 +96,7 @@ spec: {{- if eq .Values.p2pPort.type "ClusterIP" }} --p2p-tcp-address=$POD_IP:{{ .Values.p2pPort.port }} {{- else }} - --p2p-tcp-address=$EXTERNAL_IP:$EXTERNAL_PORT + --p2p-tcp-address=$EXTERNAL_IP:{{ .Values.p2pPort.nodePort }} {{- end }} env: - name: KUBERNETES_CLUSTER_DOMAIN From 7a646189307082717415ef3bd6c3e72813776159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 20:11:52 +0200 Subject: [PATCH 20/26] use host ip --- charts/charon/templates/deployment.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index 64d6bcd..8474b84 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -94,9 +94,10 @@ spec: {{- end }} exec charon run \ {{- if eq .Values.p2pPort.type "ClusterIP" }} - --p2p-tcp-address=$POD_IP:{{ .Values.p2pPort.port }} + --p2p-tcp-address=${{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.port }} {{- else }} - --p2p-tcp-address=$EXTERNAL_IP:{{ .Values.p2pPort.nodePort }} + --p2p-tcp-address=${{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.nodePort }} + --p2p-external-ip=$EXTERNAL_IP {{- end }} env: - name: KUBERNETES_CLUSTER_DOMAIN From e0572c85aece393e0d1fc04a1251f0d560861234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 20:16:53 +0200 Subject: [PATCH 21/26] remove $ sign --- charts/charon/templates/deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index 8474b84..3e10d2e 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -94,9 +94,9 @@ spec: {{- end }} exec charon run \ {{- if eq .Values.p2pPort.type "ClusterIP" }} - --p2p-tcp-address=${{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.port }} + --p2p-tcp-address={{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.port }} {{- else }} - --p2p-tcp-address=${{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.nodePort }} + --p2p-tcp-address={{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.nodePort }} --p2p-external-ip=$EXTERNAL_IP {{- end }} env: From 4ce0b15f4c4335e4e283a59c90769b28f87eb047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 20:22:27 +0200 Subject: [PATCH 22/26] remove default externalIp --- charts/charon/templates/configmap.yaml | 3 --- charts/charon/values.yaml | 3 --- 2 files changed, 6 deletions(-) diff --git a/charts/charon/templates/configmap.yaml b/charts/charon/templates/configmap.yaml index b50f2a5..2d45f98 100644 --- a/charts/charon/templates/configmap.yaml +++ b/charts/charon/templates/configmap.yaml @@ -92,12 +92,9 @@ data: echo "Namespace: ${POD_NAMESPACE} Pod: ${POD_NAME}"; {{- if eq .Values.p2pPort.type "LoadBalancer" }} until [ -n "$(kubectl -n ${POD_NAMESPACE} get svc/${POD_NAME} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" ]; do echo "Waiting for load balancer to get an IP" && sleep 10; done; - export EXTERNAL_PORT=$(kubectl -n ${POD_NAMESPACE} get services -l "type in (p2p)" -o jsonpath='{.items[0].spec.ports[0].nodePort}'); export EXTERNAL_IP=$(kubectl -n ${POD_NAMESPACE} get svc/${POD_NAME} -o jsonpath='{.status.loadBalancer.ingress[0].ip}'); {{- else if eq .Values.p2pPort.type "NodePort" }} - export EXTERNAL_PORT=$(kubectl get services -l "type in (p2p)" -o jsonpath='{.items[0].spec.ports[0].nodePort}'); export EXTERNAL_IP=$(kubectl get nodes "${NODE_NAME}" -o jsonpath='{.status.addresses[?(@.type=="ExternalIP")].address}'); {{- end }} - echo "EXTERNAL_PORT=$EXTERNAL_PORT" > /env/init-nodeport; echo "EXTERNAL_IP=$EXTERNAL_IP" >> /env/init-nodeport; cat /env/init-nodeport; diff --git a/charts/charon/values.yaml b/charts/charon/values.yaml index f5d6430..1a9d885 100644 --- a/charts/charon/values.yaml +++ b/charts/charon/values.yaml @@ -220,9 +220,6 @@ config: # -- The DNS hostname advertised by libp2p. This may be used to advertise an external DNS. p2pExternalHostname: "" - # -- The IP address advertised by libp2p. This may be used to advertise an external IP. - p2pExternalIp: "" - # -- Comma-separated list of libp2p relay URLs or multiaddrs. (default [https://0.relay.obol.tech/enr]) p2pRelays: "https://0.relay.obol.tech/enr" From 38c0ed6af4f8495c18facfe572eb3acb55f70748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 21:25:08 +0200 Subject: [PATCH 23/26] use single line appropproach --- charts/charon/templates/deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index 3e10d2e..49074fe 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -88,11 +88,11 @@ spec: command: - /bin/sh - -c - - | + - > {{- if ne .Values.p2pPort.type "ClusterIP" }} . /env/init-nodeport {{- end }} - exec charon run \ + exec charon run {{- if eq .Values.p2pPort.type "ClusterIP" }} --p2p-tcp-address={{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.port }} {{- else }} From a3fffcb7e1d57f3244d9024f97e722731223b8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 21:29:17 +0200 Subject: [PATCH 24/26] use previous approach --- charts/charon/templates/deployment.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/charon/templates/deployment.yaml b/charts/charon/templates/deployment.yaml index 49074fe..8760d3a 100644 --- a/charts/charon/templates/deployment.yaml +++ b/charts/charon/templates/deployment.yaml @@ -88,15 +88,15 @@ spec: command: - /bin/sh - -c - - > + - | {{- if ne .Values.p2pPort.type "ClusterIP" }} . /env/init-nodeport {{- end }} - exec charon run + exec charon run \ {{- if eq .Values.p2pPort.type "ClusterIP" }} --p2p-tcp-address={{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.port }} {{- else }} - --p2p-tcp-address={{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.nodePort }} + --p2p-tcp-address={{ .Values.config.p2pTcpAddress }}:{{ .Values.p2pPort.nodePort }} \ --p2p-external-ip=$EXTERNAL_IP {{- end }} env: From 76c58201bf9e55636d5b211fd1b4fe50b6e2da26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= Date: Mon, 29 Jul 2024 21:39:04 +0200 Subject: [PATCH 25/26] fix value param ref --- charts/charon/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/charon/values.yaml b/charts/charon/values.yaml index 0f46c3c..95f1edc 100644 --- a/charts/charon/values.yaml +++ b/charts/charon/values.yaml @@ -152,7 +152,7 @@ p2pPort: ## @param p2pPort.type ## Options: NodePort, LoadBalancer, ClusterIP type: NodePort - ## @param p2pNodePort.startAt The ports allocation will start from this value + ## @param p2pNodePort.nodePort The port allocation will be set to this value ## nodePort: 32000 ## @param p2pPort.port The default P2P port for charon service From bcc4d7b9f0d61a7a30404a8b4f875cc75f7a3030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20J=C4=99drzejewski?= <33068017+matilote@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:43:27 +0100 Subject: [PATCH 26/26] Update values.yaml --- charts/charon/values.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/charts/charon/values.yaml b/charts/charon/values.yaml index 95f1edc..9493d3a 100644 --- a/charts/charon/values.yaml +++ b/charts/charon/values.yaml @@ -324,11 +324,3 @@ centralMonitoring: promEndpoint: "https://vm.monitoring.gcp.obol.tech/write" # -- The authentication token to the central prometheus token: "" - resources: - {} - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi