From d9b16fe42949fb668ede49379f176f4dbac5c576 Mon Sep 17 00:00:00 2001 From: Tomer Shefler Date: Thu, 1 Feb 2024 10:48:05 +0200 Subject: [PATCH] Add helm post-delete that cleansup the CNDR /var/opt/carbonblack dirs on uninstall --- .../templates/post-delete-cndr.yaml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 charts/cbcontainers-agent/cbcontainers-agent-chart/templates/post-delete-cndr.yaml diff --git a/charts/cbcontainers-agent/cbcontainers-agent-chart/templates/post-delete-cndr.yaml b/charts/cbcontainers-agent/cbcontainers-agent-chart/templates/post-delete-cndr.yaml new file mode 100644 index 00000000..b60573a2 --- /dev/null +++ b/charts/cbcontainers-agent/cbcontainers-agent-chart/templates/post-delete-cndr.yaml @@ -0,0 +1,33 @@ +{{- range $i, $node := (lookup "v1" "Node" "" "").items }} + +apiVersion: batch/v1 +kind: Job +metadata: + name: cbcontainers-edr-sensor-cleaner + annotations: + "helm.sh/hook": "post-delete" + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed +spec: + template: + spec: +# serviceAccountName: cbcontainers-edr-sensor-cleaner + volumes: + - hostPath: + path: /var + type: Directory + name: var-dir + containers: + - name: edr-sensor-cleaner + image: photon:4.0 + imagePullPolicy: IfNotPresent + securityContext: + privileged: true + runAsUser: 0 + volumeMounts: + - mountPath: /var + name: var-dir + command: ["/usr/bin/rm", "-rf", "/var/opt/carbonblack"] + restartPolicy: Never + nodeName: "{{ $node.metadata.name }}" +--- +{{- end }} \ No newline at end of file