Skip to content

Commit

Permalink
Merge pull request #121 from celo-org/jcortejoso/celo-fullnode-delete
Browse files Browse the repository at this point in the history
Added CJ to delete pods
  • Loading branch information
jcortejoso authored Aug 22, 2023
2 parents 1655a17 + 0492f34 commit d1089d9
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/celo-fullnode/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions charts/celo-fullnode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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 |
Expand Down
3 changes: 3 additions & 0 deletions charts/celo-fullnode/ci/test-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ geth:
memory: 500Mi
cpu: 0.5
syncmode: lightest

deletePodCronJob:
enabled: true
97 changes: 97 additions & 0 deletions charts/celo-fullnode/templates/delete-pod-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{{- 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:
- |
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
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 }}
2 changes: 2 additions & 0 deletions charts/celo-fullnode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""

0 comments on commit d1089d9

Please sign in to comment.