Skip to content

Commit

Permalink
Merge pull request #126 from celo-org/jcortejoso/fullnode-delete-pvc
Browse files Browse the repository at this point in the history
Delete pvc in cj
  • Loading branch information
jcortejoso authored Aug 25, 2023
2 parents c018e8d + 3aa644c commit 425b5a1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 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.8
version: 0.5.9
dependencies:
- name: common
repository: oci://us-west1-docker.pkg.dev/devopsre/clabs-public-oci
Expand Down
9 changes: 5 additions & 4 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.8](https://img.shields.io/badge/Version-0.5.8-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.9](https://img.shields.io/badge/Version-0.5.9-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.8" # Use remote chart and specific version
CHART_RELEASE="oci://us-west1-docker.pkg.dev/celo-testnet/clabs-public-oci/celo-fullnode --version=0.5.9" # Use remote chart and specific version
CHART_RELEASE="./" # Use this local folder

# (Only for local chart) Sync helm dependencies
Expand All @@ -60,8 +60,9 @@ 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,"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 | object | `{"enabled":false,"extraFlagsPod":"","extraFlagsPvc":"","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.extraFlagsPod | string | `""` | Extra cmd flags to pass to the delete pod command |
| deletePodCronJob.extraFlagsPvc | string | `""` | Extra cmd flags to pass to the delete pvc 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
19 changes: 16 additions & 3 deletions charts/celo-fullnode/templates/delete-pod-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@ spec:
containers:
- name: restart-geth
command:
- /bin/sh
- /bin/bash
- -c
args:
- |
extraFlags="{{ .Values.deletePodCronJob.extraFlags }}"
kubectl delete pod -n {{ .Release.Namespace }} {{ printf "%s-%d" (include "common.fullname" .) (.Values.deletePodCronJob.podIndex | int) }} $extraFlags
# Delete the pod to force geth to flush the data to disk
extraFlagsPod="{{ .Values.deletePodCronJob.extraFlagsPod }}"
kubectl delete pod -n {{ .Release.Namespace }} {{ printf "%s-%d" (include "common.fullname" .) (.Values.deletePodCronJob.podIndex | int) }} $extraFlagsPod
# Delete pvc that are not currently used
extraFlagsPod="{{ .Values.deletePodCronJob.extraFlagsPvc }}"
unused_pvcs="$(kubectl describe pvc | grep -E "^Name:.*$|^Namespace:.*$|^Used By:.*$" | grep -B 2 "<none>" | grep -E "^Name:.*$")"
while IFS= read -r line; do
pvc=$(echo $line | awk '{print $2}')
echo "Deleting pvc $pvc"
kubectl delete pvc -n {{ .Release.Namespace }} $pvc $extraFlagsPvc
done <<< "$unused_pvcs"
image: bitnami/kubectl:latest
imagePullPolicy: Always
terminationMessagePath: /dev/termination-log
Expand Down Expand Up @@ -71,6 +81,9 @@ rules:
- ""
resources:
- pods
- persistentvolumes
- persistentvolumeclaims
- persistentvolumeclaims/status
verbs:
- get
- list
Expand Down
4 changes: 3 additions & 1 deletion charts/celo-fullnode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,6 @@ deletePodCronJob:
# -- Statefulset index to delete
podIndex: 0
# -- Extra cmd flags to pass to the delete pod command
extraFlags: ""
extraFlagsPod: ""
# -- Extra cmd flags to pass to the delete pvc command
extraFlagsPvc: ""

0 comments on commit 425b5a1

Please sign in to comment.