77 lines
2.0 KiB
YAML
77 lines
2.0 KiB
YAML
{{/*
|
|
#
|
|
# Copyright (c) 2020 Intel Corporation, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
*/}}
|
|
|
|
{{- if .Values.hook.cleanup.enable }}
|
|
{{ $root := . }}
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: config-rook-ceph-host-cleanup
|
|
namespace: {{ $root.Release.Namespace }}
|
|
annotations:
|
|
"helm.sh/hook": "post-delete"
|
|
"helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded"
|
|
data:
|
|
rook_host_cleanup.sh: |-
|
|
#!/bin/bash
|
|
|
|
rm -rf /var/lib/ceph/*
|
|
|
|
stat /var/lib/ceph/mon-a/ > /dev/null 2>&1
|
|
if [ x"$?" = x"0" ]; then
|
|
rm -rf /var/lib/ceph/mon-a/*
|
|
fi
|
|
|
|
exit 0
|
|
|
|
{{- range $mon_host := $root.Values.hook.cleanup.mon_hosts }}
|
|
---
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: "rook-ceph-cleanup-{{ $mon_host }}"
|
|
namespace: {{ $root.Release.Namespace }}
|
|
labels:
|
|
heritage: {{ $root.Release.Service | quote }}
|
|
release: {{ $root.Release.Name | quote }}
|
|
chart: "{{$root.Chart.Name}}-{{$root.Chart.Version}}"
|
|
annotations:
|
|
"helm.sh/hook": "post-delete"
|
|
"helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded"
|
|
spec:
|
|
template:
|
|
metadata:
|
|
name: "rook-ceph-cleanup-{{ $mon_host }}"
|
|
namespace: {{ $root.Release.Namespace }}
|
|
labels:
|
|
heritage: {{ $root.Release.Service | quote }}
|
|
release: {{ $root.Release.Name | quote }}
|
|
chart: "{{$root.Chart.Name}}-{{$root.Chart.Version}}"
|
|
spec:
|
|
restartPolicy: OnFailure
|
|
volumes:
|
|
- name: rook-data
|
|
hostPath:
|
|
path: /var/lib/ceph
|
|
- name: config-rook-ceph-host-cleanup
|
|
configMap:
|
|
name: config-rook-ceph-host-cleanup
|
|
containers:
|
|
- name: host-cleanup
|
|
image: {{ $root.Values.hook.image }}
|
|
command: [ "/bin/bash", "/tmp/mount/rook_host_cleanup.sh" ]
|
|
volumeMounts:
|
|
- name: rook-data
|
|
mountPath: /var/lib/ceph
|
|
- name: config-rook-ceph-host-cleanup
|
|
mountPath: /tmp/mount
|
|
nodeName: {{ $mon_host }}
|
|
{{- end }}
|
|
{{- end }}
|