Skip to content

Commit df0fe74

Browse files
committed
Add configuration for security contexts
1 parent 3e83da5 commit df0fe74

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

charts/rcloneproxy/templates/deployment.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,42 @@ spec:
1414
labels:
1515
app: rcloneproxy
1616
spec:
17+
{{- if .Values.podSecurityContext.enabled }}
18+
securityContext:
19+
{{- if .Values.podSecurityContext.fsGroup }}
20+
fsGroup: {{ .Values.podSecurityContext.fsGroup }}
21+
{{- end }}
22+
{{- if .Values.podSecurityContext.fsGroupChangePolicy }}
23+
fsGroupChangePolicy: {{ .Values.podSecurityContext.fsGroupChangePolicy }}
24+
{{- end }}
25+
{{- if .Values.podSecurityContext.seLinuxOptions }}
26+
seLinuxOptions:
27+
{{- toYaml .Values.podSecurityContext.seLinuxOptions | nindent 10 }}
28+
{{- end }}
29+
{{- end }}
1730
initContainers:
1831
- name: generate-config
1932
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
2033
imagePullPolicy: {{ .Values.image.pullPolicy }}
34+
{{- if .Values.containerSecurityContext.enabled }}
35+
securityContext:
36+
{{- if .Values.containerSecurityContext.runAsUser }}
37+
runAsUser: {{ .Values.containerSecurityContext.runAsUser }}
38+
{{- end }}
39+
{{- if .Values.containerSecurityContext.runAsNonRoot }}
40+
runAsNonRoot: {{ .Values.containerSecurityContext.runAsNonRoot }}
41+
{{- end }}
42+
{{- if ne .Values.containerSecurityContext.allowPrivilegeEscalation nil }}
43+
allowPrivilegeEscalation: {{ .Values.containerSecurityContext.allowPrivilegeEscalation }}
44+
{{- end }}
45+
{{- if ne .Values.containerSecurityContext.readOnlyRootFilesystem nil }}
46+
readOnlyRootFilesystem: {{ .Values.containerSecurityContext.readOnlyRootFilesystem }}
47+
{{- end }}
48+
{{- if .Values.containerSecurityContext.capabilities }}
49+
capabilities:
50+
{{- toYaml .Values.containerSecurityContext.capabilities | nindent 14 }}
51+
{{- end }}
52+
{{- end }}
2153
command:
2254
- /bin/sh
2355
- -c
@@ -94,6 +126,25 @@ spec:
94126
- name: rcloneproxy
95127
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
96128
imagePullPolicy: {{ .Values.image.pullPolicy }}
129+
{{- if .Values.containerSecurityContext.enabled }}
130+
securityContext:
131+
{{- if .Values.containerSecurityContext.runAsUser }}
132+
runAsUser: {{ .Values.containerSecurityContext.runAsUser }}
133+
{{- end }}
134+
{{- if .Values.containerSecurityContext.runAsNonRoot }}
135+
runAsNonRoot: {{ .Values.containerSecurityContext.runAsNonRoot }}
136+
{{- end }}
137+
{{- if ne .Values.containerSecurityContext.allowPrivilegeEscalation nil }}
138+
allowPrivilegeEscalation: {{ .Values.containerSecurityContext.allowPrivilegeEscalation }}
139+
{{- end }}
140+
{{- if ne .Values.containerSecurityContext.readOnlyRootFilesystem nil }}
141+
readOnlyRootFilesystem: {{ .Values.containerSecurityContext.readOnlyRootFilesystem }}
142+
{{- end }}
143+
{{- if .Values.containerSecurityContext.capabilities }}
144+
capabilities:
145+
{{- toYaml .Values.containerSecurityContext.capabilities | nindent 14 }}
146+
{{- end }}
147+
{{- end }}
97148
command:
98149
- /bin/sh
99150
- -c

charts/rcloneproxy/values.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,32 @@ resources:
4343
limits:
4444
memory: "512Mi"
4545
cpu: "25m"
46+
47+
# -- Pod security context configuration
48+
podSecurityContext:
49+
# -- Enable pod security context
50+
enabled: true
51+
# -- FSGroup for volume ownership
52+
fsGroup: 65532
53+
# -- FSGroupChangePolicy for volume ownership changes
54+
fsGroupChangePolicy: "OnRootMismatch"
55+
# -- SELinux options for OpenShift compatibility
56+
seLinuxOptions: {}
57+
# type: "spc_t"
58+
59+
# -- Container security context configuration
60+
containerSecurityContext:
61+
# -- Enable container security context
62+
enabled: true
63+
# -- Run as non-root user
64+
runAsNonRoot: true
65+
# -- User ID to run the container
66+
runAsUser: 65532
67+
# -- Disallow privilege escalation
68+
allowPrivilegeEscalation: false
69+
# -- Read-only root filesystem
70+
readOnlyRootFilesystem: false
71+
# -- Linux capabilities to drop
72+
capabilities:
73+
drop:
74+
- ALL

0 commit comments

Comments
 (0)