Merge pull request #1602 from Poor12/add-post-delete-job
Remove remaining resource when using helm uninstall
This commit is contained in:
commit
9d3a6969c7
|
@ -41,6 +41,14 @@ $ helm uninstall karmada -n karmada-system
|
||||||
```
|
```
|
||||||
|
|
||||||
The command removes all the Kubernetes components associated with the chart and deletes the release.
|
The command removes all the Kubernetes components associated with the chart and deletes the release.
|
||||||
|
> **Note**: There are some RBAC resources that are used by the `preJob` that can not be deleted by the `uninstall` command above. You might have to clean them manually with tools like `kubectl`. You can clean them by commands:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ kubectl delete sa/karmada-pre-job -nkarmada-system
|
||||||
|
$ kubectl delete clusterRole/karmada-pre-job
|
||||||
|
$ kubectl delete clusterRoleBinding/karmada-pre-job
|
||||||
|
$ kubectl delete ns karmada-system
|
||||||
|
```
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
### 1. Install agent
|
### 1. Install agent
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
{{- if and (eq .Values.installMode "host") (eq .Values.certs.mode "auto") }}
|
||||||
|
{{- $name := include "karmada.name" . -}}
|
||||||
|
{{- $namespace := include "karmada.namespace" . -}}
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: "{{ $name }}-post-delete"
|
||||||
|
namespace: {{ $namespace }}
|
||||||
|
labels:
|
||||||
|
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
||||||
|
annotations:
|
||||||
|
# This is what defines this resource as a hook. Without this line, the
|
||||||
|
# job is considered part of the release.
|
||||||
|
"helm.sh/hook": post-delete
|
||||||
|
"helm.sh/hook-weight": "0"
|
||||||
|
"helm.sh/hook-delete-policy": hook-succeeded
|
||||||
|
spec:
|
||||||
|
parallelism: 1
|
||||||
|
completions: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
labels:
|
||||||
|
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
||||||
|
spec:
|
||||||
|
serviceAccountName: {{ $name }}-pre-job
|
||||||
|
restartPolicy: Never
|
||||||
|
containers:
|
||||||
|
- name: post-delete
|
||||||
|
image: {{ .Values.postDeleteJob.postDeleteContainerImage }}
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
bash <<'EOF'
|
||||||
|
set -ex
|
||||||
|
kubectl delete -f /opt/mount/
|
||||||
|
kubectl delete cm/{{ $name }}-config -n {{ $namespace }}
|
||||||
|
EOF
|
||||||
|
volumeMounts:
|
||||||
|
- name: mount
|
||||||
|
mountPath: /opt/mount
|
||||||
|
volumes:
|
||||||
|
- name: mount
|
||||||
|
configMap:
|
||||||
|
name: {{ $name }}-config
|
||||||
|
{{- end }}
|
|
@ -26,6 +26,10 @@ preInstallJob:
|
||||||
postInstallJob:
|
postInstallJob:
|
||||||
postInstallContainerImage: bitnami/kubectl:latest
|
postInstallContainerImage: bitnami/kubectl:latest
|
||||||
|
|
||||||
|
## post-delete job config
|
||||||
|
postDeleteJob:
|
||||||
|
postDeleteContainerImage: bitnami/kubectl:latest
|
||||||
|
|
||||||
## karmada certificate config
|
## karmada certificate config
|
||||||
certs:
|
certs:
|
||||||
## @param certs.mode "auto" and "custom" are provided
|
## @param certs.mode "auto" and "custom" are provided
|
||||||
|
|
Loading…
Reference in New Issue