Skip to content

Commit 161b9cc

Browse files
committed
Cleanup TA and AM
Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
1 parent 5777099 commit 161b9cc

6 files changed

Lines changed: 141 additions & 6 deletions

File tree

helm/attestation-verifier/charts/cleanup-host/templates/job.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,10 @@ spec:
3232
volumeMounts:
3333
- name: host-volume-verifier
3434
mountPath: /tmp/verifier
35-
- name: host-volume-trustagent
36-
mountPath: /tmp/trustagent
3735
securityContext:
3836
{{- toYaml .Values.securityContext.cleanupHost | nindent 12 }}
3937
volumes:
4038
- name: host-volume-verifier
4139
hostPath:
4240
path: /opt/verifier
4341
type: ""
44-
- name: host-volume-trustagent
45-
hostPath:
46-
path: /opt/trustagent
47-
type: ""
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v2
2+
appVersion: 0.1.0
3+
dependencies:
4+
- name: factory
5+
repository: file://../../charts/factory/
6+
version: 0.1.0
7+
description: A Helm chart for cleaning up folders create post helm uninstall of a release
8+
name: cleanup-host
9+
type: application
10+
version: 0.1.0
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "cleanup-ta.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create chart name and version as used by the chart label.
10+
*/}}
11+
{{- define "cleanup-ta.chart" -}}
12+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
13+
{{- end }}
14+
15+
{{/*
16+
Common labels
17+
*/}}
18+
{{- define "cleanup-ta.labels" -}}
19+
helm.sh/chart: {{ include "cleanup-ta.chart" . }}
20+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
21+
app.kubernetes.io/name: {{ include "cleanup-ta.name" . }}
22+
{{- end }}
23+
24+
{{/*
25+
Selector labels
26+
*/}}
27+
{{- define "cleanup-ta.selectorLabels" -}}
28+
app.kubernetes.io/name: {{ include "cleanup-ta.name" . }}
29+
{{- end }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{{- include "factory.headers" . }}
2+
---
3+
apiVersion: batch/v1
4+
kind: Job
5+
metadata:
6+
name: {{ include "cleanup-ta.name" . }}
7+
namespace: {{ .Release.Namespace }}
8+
labels:
9+
{{- include "cleanup-ta.labels" . | nindent 4 }}
10+
annotations:
11+
"helm.sh/hook": post-delete
12+
"helm.sh/hook-delete-policy": hook-succeeded
13+
spec:
14+
template:
15+
metadata:
16+
labels:
17+
{{- include "cleanup-ta.labels" . | nindent 8 }}
18+
spec:
19+
securityContext:
20+
{{- toYaml .Values.securityContext.cleanupHostInit | nindent 8 }}
21+
serviceAccountName: {{ include "factory.name" . }}
22+
restartPolicy: Never
23+
containers:
24+
- name: cleanup-ta
25+
image: debian:bullseye-slim
26+
imagePullPolicy: Always
27+
command: ["/bin/sh", "-c"]
28+
args:
29+
- >
30+
echo deleting &&
31+
rm -rf /tmp/trustagent && /tmp/attestation-manager
32+
volumeMounts:
33+
- name: host-volume-trustagent
34+
mountPath: /tmp/trustagent
35+
volumeMounts:
36+
- name: host-volume-am
37+
mountPath: /tmp/attestation-manager
38+
securityContext:
39+
{{- toYaml .Values.securityContext.cleanupHost | nindent 12 }}
40+
volumes:
41+
- name: host-volume-trustagent
42+
hostPath:
43+
path: /opt/trustagent
44+
type: ""
45+
- name: host-volume-am
46+
hostPath:
47+
path: /tmp/attestation-manager
48+
type: ""
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{- include "factory.headers" . }}
2+
---
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: {{ include "factory.name" . }}
7+
namespace: {{ .Release.Namespace }}
8+
annotations:
9+
"helm.sh/hook": pre-install, pre-upgrade
10+
"helm.sh/hook-weight": "-5"
11+
---
12+
apiVersion: rbac.authorization.k8s.io/v1
13+
kind: Role
14+
metadata:
15+
name: {{ include "factory.name" . }}
16+
namespace: {{ .Release.Namespace }}
17+
annotations:
18+
"helm.sh/hook": pre-install, pre-upgrade
19+
"helm.sh/hook-weight": "-5"
20+
rules:
21+
- apiGroups: ["batch"]
22+
resources: ["host"]
23+
verbs: ["delete","list"]
24+
---
25+
apiVersion: rbac.authorization.k8s.io/v1
26+
kind: RoleBinding
27+
metadata:
28+
name: {{ include "factory.name" . }}
29+
namespace: {{ .Release.Namespace }}
30+
annotations:
31+
"helm.sh/hook": pre-install, pre-upgrade
32+
"helm.sh/hook-weight": "-5"
33+
subjects:
34+
- kind: ServiceAccount
35+
name: {{ include "factory.name" . }}
36+
namespace: {{ .Release.Namespace }}
37+
roleRef:
38+
kind: Role
39+
name: {{ include "factory.name" . }}
40+
apiGroup: rbac.authorization.k8s.io
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Default values for cleanup-host.
2+
3+
nameOverride: "" # The name for CLEANUP-HOST chart (Default: .Chart.Name)
4+
5+
securityContext:
6+
cleanupHostInit: # The fsGroup id for init containers for Cleanup host
7+
fsGroup: 0
8+
cleanupHost: # The security content for Cleanup host
9+
runAsUser: 0
10+
runAsGroup: 0
11+
capabilities:
12+
drop:
13+
- all
14+
allowPrivilegeEscalation: false

0 commit comments

Comments
 (0)