Skip to content

Commit edc2803

Browse files
Merge pull request #717 from kate-goldenring/helm-delete-configs-hook
Add Helm pre-delete hook to remove configurations before Akri chart c…
2 parents d456ca3 + 396b398 commit edc2803

File tree

8 files changed

+432
-90
lines changed

8 files changed

+432
-90
lines changed

Cargo.lock

+349-85
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ members = [
2323
resolver = "2"
2424

2525
[workspace.package]
26-
version = "0.13.7"
26+
version = "0.13.8"
2727
edition = "2021"
2828
license = "Apache-2.0"
2929
homepage = "https://docs.akri.sh/"

deployment/helm/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ type: application
1616
# This is the chart version. This version number should be incremented each time you make changes
1717
# to the chart and its templates, including the app version.
1818
# Versions are expected to follow Semantic Versioning (https://semver.org/)
19-
version: 0.13.7
19+
version: 0.13.8
2020

2121
# This is the version number of the application being deployed. This version number should be
2222
# incremented each time you make changes to the application. Versions are not expected to
2323
# follow Semantic Versioning. They should reflect the version the application is using.
24-
appVersion: 0.13.7
24+
appVersion: 0.13.8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{{- if .Values.cleanupHook.enabled }}
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: "{{ .Release.Name }}-cleanup"
6+
labels:
7+
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
8+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
9+
app.kubernetes.io/version: {{ .Chart.AppVersion }}
10+
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
11+
annotations:
12+
# This is what defines this resource as a hook. Without this line, the
13+
# job is considered part of the release.
14+
"helm.sh/hook": pre-delete
15+
"helm.sh/hook-weight": "-5"
16+
"helm.sh/hook-delete-policy": hook-succeeded
17+
spec:
18+
template:
19+
metadata:
20+
name: "{{ .Release.Name }}"
21+
labels:
22+
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
23+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
24+
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
25+
app.kubernetes.io/component: helm-hook
26+
spec:
27+
restartPolicy: Never
28+
serviceAccountName: akri-helm-cleanup-hook-sa
29+
containers:
30+
- name: delete-configurations
31+
image: bitnami/kubectl:latest
32+
command: ["/bin/sh", "-c"]
33+
args: [
34+
"kubectl delete configurations.akri.sh --all --all-namespaces --wait"
35+
]
36+
{{- end }}

deployment/helm/templates/rbac.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,39 @@ subjects:
9090
- kind: 'ServiceAccount'
9191
name: 'akri-agent-sa'
9292
namespace: {{ .Release.Namespace }}
93+
{{- if .Values.cleanupHook.enabled }}
94+
---
95+
apiVersion: v1
96+
kind: ServiceAccount
97+
metadata:
98+
name: akri-helm-cleanup-hook-sa
99+
labels:
100+
app.kubernetes.io/component: helm-hook
101+
---
102+
kind: ClusterRole
103+
apiVersion: rbac.authorization.k8s.io/v1
104+
metadata:
105+
name: "akri-helm-cleanup-hook-role"
106+
labels:
107+
app.kubernetes.io/component: helm-hook
108+
rules:
109+
- apiGroups: [{{ .Values.crds.group | quote }}]
110+
resources: ["configurations"]
111+
verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"]
112+
---
113+
apiVersion: 'rbac.authorization.k8s.io/v1'
114+
kind: 'ClusterRoleBinding'
115+
metadata:
116+
name: "akri-helm-cleanup-hook-binding"
117+
labels:
118+
app.kubernetes.io/component: helm-hook
119+
roleRef:
120+
apiGroup: ''
121+
kind: 'ClusterRole'
122+
name: 'akri-helm-cleanup-hook-role'
123+
subjects:
124+
- kind: 'ServiceAccount'
125+
name: 'akri-helm-cleanup-hook-sa'
126+
namespace: {{ .Release.Namespace }}
127+
{{- end }}
93128
{{- end }}

deployment/helm/values.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ useDevelopmentContainers: true
1616
# This can be set from the helm command line using `--set imagePullSecrets[0].name="mysecret"`
1717
imagePullSecrets: []
1818

19+
cleanupHook:
20+
# enabled defines whether to enable the Helm pre-delete hook to cleanup
21+
# Configurations during chart deletion. Also applies associated RBAC for the
22+
# hook. More information on Helm hooks:
23+
# https://helm.sh/docs/topics/charts_hooks/
24+
enabled: true
25+
1926
# generalize references to `apiGroups` and `apiVersion` values for Akri CRDs
2027
crds:
2128
group: akri.sh

discovery-handlers/onvif/src/discovery_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub mod util {
179179
/// Get SOAP probe message with a specific message id
180180
fn get_expected_probe_message(message_id: &str) -> String {
181181
format!(
182-
"<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header xmlns:w=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><w:MessageID>{}</w:MessageID><w:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To><w:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</w:Action></s:Header><s:Body xmlns:d=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\"><d:Probe><d:Types>netwsdl:NetworkVideoTransmitter</d:Types></d:Probe></s:Body></s:Envelope>",
182+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header xmlns:w=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><w:MessageID>{}</w:MessageID><w:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To><w:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</w:Action></s:Header><s:Body xmlns:d=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\"><d:Probe><d:Types>netwsdl:NetworkVideoTransmitter</d:Types></d:Probe></s:Body></s:Envelope>",
183183
&message_id)
184184
}
185185

version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.13.7
1+
0.13.8

0 commit comments

Comments
 (0)