From a98fe9af5285ab131d7ace6292d85e3f686e72f8 Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Tue, 22 Aug 2023 16:37:45 +0200 Subject: [PATCH 1/4] Added CJ to delete pods --- charts/celo-fullnode/Chart.yaml | 2 +- charts/celo-fullnode/ci/test-values.yaml | 3 + .../templates/delete-pod-cronjob.yaml | 96 +++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 charts/celo-fullnode/templates/delete-pod-cronjob.yaml diff --git a/charts/celo-fullnode/Chart.yaml b/charts/celo-fullnode/Chart.yaml index b2cce4fa..6f88204c 100644 --- a/charts/celo-fullnode/Chart.yaml +++ b/charts/celo-fullnode/Chart.yaml @@ -19,7 +19,7 @@ keywords: - Validator - Ethereum - Proof-of-Stake -version: 0.5.4 +version: 0.5.5 dependencies: - name: common repository: oci://us-west1-docker.pkg.dev/devopsre/clabs-public-oci diff --git a/charts/celo-fullnode/ci/test-values.yaml b/charts/celo-fullnode/ci/test-values.yaml index a8753077..6076a3f2 100644 --- a/charts/celo-fullnode/ci/test-values.yaml +++ b/charts/celo-fullnode/ci/test-values.yaml @@ -12,3 +12,6 @@ geth: memory: 500Mi cpu: 0.5 syncmode: lightest + +deletePodCronJob: + enabled: true diff --git a/charts/celo-fullnode/templates/delete-pod-cronjob.yaml b/charts/celo-fullnode/templates/delete-pod-cronjob.yaml new file mode 100644 index 00000000..6227ca16 --- /dev/null +++ b/charts/celo-fullnode/templates/delete-pod-cronjob.yaml @@ -0,0 +1,96 @@ +{{- if .Values.deletePodCronJob.enabled -}} +{{- /* +This CronJob in intended to delete regularly a geth pod +in order to force geth to flush the data to disk, so it can +be used as an snapshot +*/}} +apiVersion: batch/v1 +kind: CronJob +metadata: + labels: + {{- include "common.standard.labels" . | nindent 4 }} + component: restart-geth + name: {{ template "common.fullname" . }}-restart-geth +spec: + concurrencyPolicy: Forbid + failedJobsHistoryLimit: 1 + jobTemplate: + spec: + backoffLimit: 1 + template: + metadata: + labels: + {{- include "common.standard.labels" . | nindent 12 }} + component: restart-geth + spec: + containers: + - name: restart-geth + command: + - /bin/sh + - -c + args: + - | + kubectl delete pod -n {{ .Release.Namespace }} {{ printf "%s-%d" (include "common.fullname" .) (.Values.deletePodCronJob.podIndex | int) }} + image: bitnami/kubectl:latest + imagePullPolicy: Always + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Never + schedulerName: default-scheduler + serviceAccountName: {{ template "common.fullname" . }}-restart-geth + terminationGracePeriodSeconds: 30 + schedule: "{{ .Values.deletePodCronJob.schedule }}" + successfulJobsHistoryLimit: 3 + suspend: true +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + {{- include "common.standard.labels" . | nindent 4 }} + component: restart-geth + name: {{ template "common.fullname" . }}-restart-geth +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + labels: + {{- include "common.standard.labels" . | nindent 4 }} + component: restart-geth + name: {{ template "common.fullname" . }}-restart-geth +rules: +- apiGroups: + - "" + resources: + - namespaces + verbs: + - get +- apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - watch + - delete + - update + - patch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: + {{- include "common.standard.labels" . | nindent 4 }} + component: restart-geth + name: {{ template "common.fullname" . }}-restart-geth +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ template "common.fullname" . }}-restart-geth +subjects: +- kind: ServiceAccount + name: {{ template "common.fullname" . }}-restart-geth + namespace: {{ .Release.Namespace }} +{{- end }} From dc2c97f8720026c59af8b362db616830d13e5f1b Mon Sep 17 00:00:00 2001 From: jcortejoso Date: Tue, 22 Aug 2023 14:41:11 +0000 Subject: [PATCH 2/4] [Automatic] - Update chart README.md --- charts/celo-fullnode/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/celo-fullnode/README.md b/charts/celo-fullnode/README.md index 83425329..07f151ae 100644 --- a/charts/celo-fullnode/README.md +++ b/charts/celo-fullnode/README.md @@ -2,7 +2,7 @@ Helm chart for deploying a Celo fullnode. More info at https://docs.celo.org -![Version: 0.5.4](https://img.shields.io/badge/Version-0.5.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.6.0](https://img.shields.io/badge/AppVersion-1.6.0-informational?style=flat-square) +![Version: 0.5.5](https://img.shields.io/badge/Version-0.5.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.6.0](https://img.shields.io/badge/AppVersion-1.6.0-informational?style=flat-square) - [celo-fullnode](#celo-fullnode) - [Chart requirements](#chart-requirements) @@ -34,7 +34,7 @@ To install/manage a release named `celo-mainnet-fullnode` connected to `mainnet` ```bash # Select the chart release to use -CHART_RELEASE="oci://us-west1-docker.pkg.dev/celo-testnet/clabs-public-oci/celo-fullnode --version=0.5.4" # Use remote chart and specific version +CHART_RELEASE="oci://us-west1-docker.pkg.dev/celo-testnet/clabs-public-oci/celo-fullnode --version=0.5.5" # Use remote chart and specific version CHART_RELEASE="./" # Use this local folder # (Only for local chart) Sync helm dependencies From bb59a429f08c8bbb373bfd69f06563ed09781eeb Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Tue, 22 Aug 2023 16:42:52 +0200 Subject: [PATCH 3/4] Added extraFlag value for CJ delete pod --- charts/celo-fullnode/templates/delete-pod-cronjob.yaml | 3 ++- charts/celo-fullnode/values.yaml | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/charts/celo-fullnode/templates/delete-pod-cronjob.yaml b/charts/celo-fullnode/templates/delete-pod-cronjob.yaml index 6227ca16..198fbfbc 100644 --- a/charts/celo-fullnode/templates/delete-pod-cronjob.yaml +++ b/charts/celo-fullnode/templates/delete-pod-cronjob.yaml @@ -30,7 +30,8 @@ spec: - -c args: - | - kubectl delete pod -n {{ .Release.Namespace }} {{ printf "%s-%d" (include "common.fullname" .) (.Values.deletePodCronJob.podIndex | int) }} + extraFlags="{{ .Values.deletePodCronJob.extraFlags }}" + kubectl delete pod -n {{ .Release.Namespace }} "${extraFlags}" {{ printf "%s-%d" (include "common.fullname" .) (.Values.deletePodCronJob.podIndex | int) }} image: bitnami/kubectl:latest imagePullPolicy: Always terminationMessagePath: /dev/termination-log diff --git a/charts/celo-fullnode/values.yaml b/charts/celo-fullnode/values.yaml index cda37a09..16616483 100644 --- a/charts/celo-fullnode/values.yaml +++ b/charts/celo-fullnode/values.yaml @@ -208,3 +208,5 @@ deletePodCronJob: schedule: "0 10 * * 1,4" # -- Statefulset index to delete podIndex: 0 + # -- Extra cmd flags to pass to the delete pod command + extraFlags: "" From 0492f3476d8eb8ccd5c89f1feb5c75fec26cc30e Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Tue, 22 Aug 2023 16:43:24 +0200 Subject: [PATCH 4/4] Added extraFlag value for CJ delete pod --- charts/celo-fullnode/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/celo-fullnode/README.md b/charts/celo-fullnode/README.md index 07f151ae..e1f3abf7 100644 --- a/charts/celo-fullnode/README.md +++ b/charts/celo-fullnode/README.md @@ -60,7 +60,8 @@ helm upgrade celo-mainnet-fullnode -f values-mainnet-node.yaml --namespace=celo |-----|------|---------|-------------| | aws | bool | `false` | Enables aws specific settings | | azure | bool | `false` | Enables azure specific settings | -| deletePodCronJob | object | `{"enabled":false,"podIndex":0,"schedule":"0 10 * * 1,4"}` | Enable a CronJob that will delete a pod of the statefulset to force flushing the data to disk | +| deletePodCronJob | object | `{"enabled":false,"extraFlags":"","podIndex":0,"schedule":"0 10 * * 1,4"}` | Enable a CronJob that will delete a pod of the statefulset to force flushing the data to disk | +| deletePodCronJob.extraFlags | string | `""` | Extra cmd flags to pass to the delete pod command | | deletePodCronJob.podIndex | int | `0` | Statefulset index to delete | | deletePodCronJob.schedule | string | `"0 10 * * 1,4"` | Cron expression for the CronJob | | extraPodLabels | object | `{}` | Labels to add to the podTemplateSpec from statefulset |