From 66abea094c184736307d3dac1d6a67267d640757 Mon Sep 17 00:00:00 2001 From: Stephane Segning Lambou Date: Fri, 22 Nov 2024 16:03:57 +0100 Subject: [PATCH] feat: cleanup volume --- README.md | 2 +- charts/wazuh/Chart.yaml | 2 +- .../templates/manager/sts.wazuh-master.yaml | 7 +-- .../templates/manager/sts.wazuh-worker.yaml | 5 ++- charts/wazuh/values-cleanup.yaml | 45 +++++++++++++++++++ charts/wazuh/values.yaml | 4 +- 6 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 charts/wazuh/values-cleanup.yaml diff --git a/README.md b/README.md index cedfb17..dacc32a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Wazuh Helm chart -[![Helm Publish](https://github.com/ADORSYS-GIS/wazuh-helm/actions/workflows/helm-publish.yml/badge.svg)](https://github.com/ADORSYS-GIS/wazuh-helm/actions/workflows/helm-publish.yml) +[![Helm Publish](https://github.com/ADORSYS-GIS/wazuh-helm/actions/workflows/helm-publish.yml/badge.svg)](https://github.com/ADORSYS-GIS/wazuh-helm/actions/workflows/helm-publish.yml) [![Build Docker image](https://github.com/ADORSYS-GIS/wazuh-helm/actions/workflows/build-envsubst.yml/badge.svg)](https://github.com/ADORSYS-GIS/wazuh-helm/actions/workflows/build-envsubst.yml) To use this chart, you need to have first a root CA. To create one you can use the following commands: diff --git a/charts/wazuh/Chart.yaml b/charts/wazuh/Chart.yaml index a875837..df988c9 100644 --- a/charts/wazuh/Chart.yaml +++ b/charts/wazuh/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.14 +version: 0.2.15 # 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/wazuh/templates/manager/sts.wazuh-master.yaml b/charts/wazuh/templates/manager/sts.wazuh-master.yaml index b5910dc..30b3a62 100644 --- a/charts/wazuh/templates/manager/sts.wazuh-master.yaml +++ b/charts/wazuh/templates/manager/sts.wazuh-master.yaml @@ -64,6 +64,10 @@ spec: {{ include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8}} {{- end }} initContainers: + {{ range $k, $v := .initContainers }} + - name: {{ include "common.tplvalues.render" (dict "value" $k "context" $) }} + {{ include "common.tplvalues.render" (dict "value" $v "context" $) | nindent 10}} + {{- end }} - name: wazuh-init ## ## @@ -102,9 +106,6 @@ spec: readOnly: true - name: wazuh-config-temp mountPath: /processed - {{ with .initContainers -}} - {{ include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8}} - {{- end }} securityContext: fsGroup: 1000 containers: diff --git a/charts/wazuh/templates/manager/sts.wazuh-worker.yaml b/charts/wazuh/templates/manager/sts.wazuh-worker.yaml index f76cf5c..93aa15d 100644 --- a/charts/wazuh/templates/manager/sts.wazuh-worker.yaml +++ b/charts/wazuh/templates/manager/sts.wazuh-worker.yaml @@ -107,8 +107,9 @@ spec: readOnly: true - name: wazuh-config-temp mountPath: /processed - {{ with .initContainers -}} - {{ include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8}} + {{ range $k, $v := .initContainers }} + - name: {{ include "common.tplvalues.render" (dict "value" $k "context" $) }} + {{ include "common.tplvalues.render" (dict "value" $v "context" $) | nindent 10}} {{- end }} securityContext: fsGroup: 1000 diff --git a/charts/wazuh/values-cleanup.yaml b/charts/wazuh/values-cleanup.yaml new file mode 100644 index 0000000..864e616 --- /dev/null +++ b/charts/wazuh/values-cleanup.yaml @@ -0,0 +1,45 @@ +worker: + initContainers: + # Cleanup residue files in PV + cleanup-pv: + image: busybox + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + cpu: 100m + memory: 256Mi + command: + - /bin/sh + - -c + - | + set -ex + # Clear any existing files in the persistent volume + rm -rf /var/ossec/* + volumeMounts: + - mountPath: /var/ossec + name: '{{ include "common.names.fullname" $ }}-manager-worker' + +master: + initContainers: + # Cleanup residue files in PV + cleanup-pv: + image: busybox + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + cpu: 100m + memory: 256Mi + command: + - /bin/sh + - -c + - | + set -ex + # Clear any existing files in the persistent volume + rm -rf /var/ossec/* + volumeMounts: + - mountPath: /var/ossec + name: '{{ include "common.names.fullname" $ }}-manager-master' \ No newline at end of file diff --git a/charts/wazuh/values.yaml b/charts/wazuh/values.yaml index d98c080..4d1c063 100644 --- a/charts/wazuh/values.yaml +++ b/charts/wazuh/values.yaml @@ -309,7 +309,7 @@ worker: ## ## - initContainers: [ ] + initContainers: { } ## ## env: [ ] @@ -450,7 +450,7 @@ master: type: RollingUpdate ## initContainers: - - name: permission-fix + permission-fix: image: busybox resources: requests: