Skip to content

Commit c35f084

Browse files
committed
Hardening: add security context; split geonode PVC into individual PVCs, to allow more granular handling and better control of subdirectory creation (avoid subPath). Note: requires a Geoserver Docker image which supports non-root runtime
1 parent 75df8f6 commit c35f084

1 file changed

Lines changed: 35 additions & 8 deletions

File tree

charts/geonode/templates/geoserver/geoserver-deploy.yaml

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,26 @@ spec:
1919
checksum/geoserver-secret: {{ include (print $.Template.BasePath "/geoserver/geoserver-secret.yaml") . | sha256sum }}
2020

2121
spec:
22+
securityContext:
23+
runAsNonRoot: true
24+
fsGroup: {{ .Values.geoserver.securityContext.fsGroup | default .Values.global.securityContext.fsGroup }}
25+
fsGroupChangePolicy: OnRootMismatch
26+
2227
terminationGracePeriodSeconds: 3
2328
initContainers:
2429
- name: {{ .Values.geoserver_data.container_name }}
30+
securityContext:
31+
runAsUser: {{ .Values.geoserver.securityContext.runAsUser | default .Values.global.securityContext.runAsUser }}
32+
runAsGroup: {{ .Values.geoserver.securityContext.runAsGroup | default .Values.global.securityContext.runAsGroup }}
33+
runAsNonRoot: true
34+
allowPrivilegeEscalation: false
35+
36+
capabilities:
37+
drop:
38+
- ALL
39+
40+
seccompProfile:
41+
type: RuntimeDefault
2542
image: "{{ .Values.geoserver_data.image.name }}:{{ .Values.geoserver_data.image.tag }}"
2643
imagePullPolicy: {{ .Values.geoserver_data.imagePullPolicy }}
2744
command:
@@ -46,9 +63,8 @@ spec:
4663
- secretRef:
4764
name: {{ .Values.geoserver.secret.existingSecretName | default (include "geoserver_secret_name" .) | quote }}
4865
volumeMounts:
49-
- name: "{{ include "persistant_volume_name" . }}"
66+
- name: pvc-geoserver-data
5067
mountPath: /geoserver_data/data
51-
subPath: geoserver-data-dir
5268
- name: geoserver-printing-config-yaml
5369
mountPath: /overrides
5470

@@ -59,6 +75,16 @@ spec:
5975

6076
containers:
6177
- name: {{ .Values.geoserver.container_name }}
78+
securityContext:
79+
runAsUser: {{ .Values.geoserver.securityContext.runAsUser | default .Values.global.securityContext.runAsUser }}
80+
runAsGroup: {{ .Values.geoserver.securityContext.runAsGroup | default .Values.global.securityContext.runAsGroup }}
81+
runAsNonRoot: true
82+
allowPrivilegeEscalation: false
83+
capabilities:
84+
drop:
85+
- ALL
86+
seccompProfile:
87+
type: RuntimeDefault
6288
image: "{{ .Values.geoserver.image.name }}:{{ .Values.geoserver.image.tag }}"
6389
imagePullPolicy: {{ .Values.geoserver.imagePullPolicy }}
6490
ports:
@@ -82,12 +108,10 @@ spec:
82108
{{- end }}
83109

84110
volumeMounts:
85-
- name: "{{ include "persistant_volume_name" . }}"
111+
- name: pvc-geoserver-data
86112
mountPath: /geoserver_data/data
87-
subPath: geoserver-data-dir
88-
- name: "{{ include "persistant_volume_name" . }}"
113+
- name: pvc-statics
89114
mountPath: /mnt/volumes/statics
90-
subPath: statics
91115

92116
readinessProbe:
93117
{{- toYaml $.Values.geoserver.readinessProbe | nindent 10 }}
@@ -102,6 +126,9 @@ spec:
102126
- name: geoserver-printing-config-yaml
103127
configMap:
104128
name: {{ .Release.Name }}-geoserver-printing-config-yaml
105-
- name: "{{ include "persistant_volume_name" . }}"
129+
- name: pvc-geoserver-data
130+
persistentVolumeClaim:
131+
claimName: {{ include "pvc_geoserver_data_name" . }}
132+
- name: pvc-statics
106133
persistentVolumeClaim:
107-
claimName: pvc-{{ .Release.Name }}-geonode
134+
claimName: {{ include "pvc_statics_name" . }}

0 commit comments

Comments
 (0)