Skip to content

Commit 47030e8

Browse files
Merge pull request #1850 from yiannistri/52501-hardened
fix: Set `securityContext` field to Turtles controller and hooks manifests
2 parents dac91f3 + 3f69b7b commit 47030e8

File tree

6 files changed

+63
-5
lines changed

6 files changed

+63
-5
lines changed

charts/rancher-turtles/templates/clusterctl-cm-cleanup-job.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,14 @@ spec:
6262
- --namespace={{ .Values.namespace }}
6363
- clusterctl-config
6464
- --ignore-not-found=true
65+
securityContext:
66+
seccompProfile:
67+
type: RuntimeDefault
68+
allowPrivilegeEscalation: false
69+
capabilities:
70+
drop:
71+
- ALL
72+
runAsNonRoot: true
73+
runAsUser: 1000
6574
restartPolicy: Never
6675
{{- end }}

charts/rancher-turtles/templates/core-provider.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
{{- if index .Values "cluster-api-operator" "cluster-api" "enabled" }}
2-
{{- $namespace := index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }}
3-
{{- if not (lookup "v1" "Namespace" "" $namespace) }}
42
---
53
apiVersion: v1
64
kind: Namespace
75
metadata:
8-
annotations:
9-
"helm.sh/hook-weight": "1"
106
name: {{ index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }}
11-
{{- end }}
127
---
138
apiVersion: turtles-capi.cattle.io/v1alpha1
149
kind: CAPIProvider

charts/rancher-turtles/templates/deployment.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ spec:
7575
volumeMounts:
7676
{{- toYaml . | nindent 12 }}
7777
{{- end }}
78+
securityContext:
79+
seccompProfile:
80+
type: RuntimeDefault
81+
allowPrivilegeEscalation: false
82+
capabilities:
83+
drop:
84+
- ALL
85+
runAsNonRoot: true
86+
runAsUser: 65532
7887
serviceAccountName: rancher-turtles-manager
7988
terminationGracePeriodSeconds: 10
8089
{{- with .Values.volumes }}

charts/rancher-turtles/templates/post-delete-job.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ spec:
6969
- mutatingwebhookconfigurations.admissionregistration.k8s.io
7070
- capi-mutating-webhook-configuration
7171
- --ignore-not-found=true
72+
securityContext:
73+
seccompProfile:
74+
type: RuntimeDefault
75+
allowPrivilegeEscalation: false
76+
capabilities:
77+
drop:
78+
- ALL
79+
runAsNonRoot: true
80+
runAsUser: 1000
7281
restartPolicy: Never
7382
---
7483
apiVersion: batch/v1
@@ -93,6 +102,15 @@ spec:
93102
- validatingwebhookconfigurations.admissionregistration.k8s.io
94103
- capi-validating-webhook-configuration
95104
- --ignore-not-found=true
105+
securityContext:
106+
seccompProfile:
107+
type: RuntimeDefault
108+
allowPrivilegeEscalation: false
109+
capabilities:
110+
drop:
111+
- ALL
112+
runAsNonRoot: true
113+
runAsUser: 1000
96114
restartPolicy: Never
97115
---
98116
apiVersion: batch/v1
@@ -119,4 +137,13 @@ spec:
119137
- -n
120138
- {{ index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }}
121139
- --ignore-not-found=true
140+
securityContext:
141+
seccompProfile:
142+
type: RuntimeDefault
143+
allowPrivilegeEscalation: false
144+
capabilities:
145+
drop:
146+
- ALL
147+
runAsNonRoot: true
148+
runAsUser: 1000
122149
{{- end }}

charts/rancher-turtles/templates/post-upgrade-job.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ spec:
112112
args:
113113
- "-c"
114114
- "/scripts/cleanup.sh"
115+
securityContext:
116+
seccompProfile:
117+
type: RuntimeDefault
118+
allowPrivilegeEscalation: false
119+
capabilities:
120+
drop:
121+
- ALL
122+
runAsNonRoot: true
123+
runAsUser: 1000
115124
volumeMounts:
116125
- name: script
117126
mountPath: /scripts

charts/rancher-turtles/templates/pre-delete-job.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,14 @@ spec:
6565
- {{ index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }}
6666
- --ignore-not-found=true
6767
- --cascade=foreground
68+
securityContext:
69+
seccompProfile:
70+
type: RuntimeDefault
71+
allowPrivilegeEscalation: false
72+
capabilities:
73+
drop:
74+
- ALL
75+
runAsNonRoot: true
76+
runAsUser: 1000
6877
restartPolicy: Never
6978
{{- end }}

0 commit comments

Comments
 (0)