Skip to content

Commit f73a440

Browse files
Jonathan S. Katzjkatz
authored andcommitted
Explicitly set Pod security policies to run as non root
The containers are already running as non-root users, so this makes it explicit that this is / must be enforced. Issue: [ch10570]
1 parent 84c9d6a commit f73a440

File tree

13 files changed

+34
-31
lines changed

13 files changed

+34
-31
lines changed

deploy/deployment.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
},
2525
"spec": {
2626
"serviceAccountName": "postgres-operator",
27+
"securityContext": {
28+
"runAsNonRoot": true
29+
},
2730
"containers": [
2831
{
2932
"name": "apiserver",

installers/ansible/roles/pgo-operator/files/pgo-configs/pgadmin-template.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@
3434
},
3535
"spec": {
3636
"serviceAccountName": "pgo-default",
37-
{{ if not .DisableFSGroup }}
3837
"securityContext": {
39-
"fsGroup": 2
38+
{{ if not .DisableFSGroup }}
39+
"fsGroup": 2,
40+
{{ end }}
41+
"runAsNonRoot": true
4042
},
41-
{{ end }}
4243
"containers": [{
4344
"name": "pgadminweb",
4445
"image": "{{.CCPImagePrefix}}/crunchy-pgadmin4:{{.CCPImageTag}}",

installers/ansible/roles/pgo-operator/files/pgo-configs/pgbouncer-template.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@
3939
},
4040
"spec": {
4141
"serviceAccountName": "pgo-default",
42-
{{ if not .DisableFSGroup }}
4342
"securityContext": {
44-
"fsGroup": 2
43+
{{ if not .DisableFSGroup }}
44+
"fsGroup": 2,
45+
{{ end }}
46+
"runAsNonRoot": true
4547
},
46-
{{ end }}
4748
"containers": [{
4849
"name": "pgbouncer",
4950
"image": "{{.CCPImagePrefix}}/crunchy-pgbouncer:{{.CCPImageTag}}",

installers/ansible/roles/pgo-operator/files/pgo-configs/pgo.sqlrunner-template.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
},
2222
"spec": {
2323
"serviceAccountName": "pgo-default",
24+
"securityContext": {
25+
"runAsNonRoot": true
26+
},
2427
{{ if .Tolerations }}
2528
"tolerations": {{ .Tolerations }},
2629
{{ end }}

installers/ansible/roles/pgo-operator/files/pgo-configs/rmdata-job.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
},
2222
"spec": {
2323
"serviceAccountName": "pgo-target",
24+
"securityContext": {
25+
"runAsNonRoot": true
26+
},
2427
{{ if .Tolerations }}
2528
"tolerations": {{ .Tolerations }},
2629
{{ end }}

installers/ansible/roles/pgo-operator/templates/deployment.json.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
},
2525
"spec": {
2626
"serviceAccountName": "postgres-operator",
27+
"securityContext": {
28+
"runAsNonRoot": true
29+
},
2730
"containers": [
2831
{
2932
"name": "apiserver",

installers/metrics/ansible/roles/pgo-metrics/templates/alertmanager-deployment.json.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
{% if not (disable_fsgroup | default(false) | bool) %}
3131
{% if (alertmanager_supplemental_groups | default('')) != '' %},{% endif -%}
3232
"fsGroup": 26,
33-
"runAsUser": 2
33+
"runAsUser": 2,
34+
"runAsNonRoot": true
3435
{% endif %}
3536
},
3637
"serviceAccountName": "alertmanager",

installers/metrics/ansible/roles/pgo-metrics/templates/grafana-deployment.json.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
{% if not (disable_fsgroup | default(false) | bool) %}
3131
{% if (grafana_supplemental_groups | default('')) != '' %},{% endif -%}
3232
"fsGroup": 26,
33-
"runAsUser": 2
33+
"runAsUser": 2,
34+
"runAsNonRoot": true
3435
{% endif %}
3536
},
3637
"serviceAccountName": "grafana",

installers/metrics/ansible/roles/pgo-metrics/templates/prometheus-deployment.json.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
{% if not (disable_fsgroup | default(false) | bool) %}
3131
{% if (prometheus_supplemental_groups | default('')) != '' %},{% endif -%}
3232
"fsGroup": 26,
33-
"runAsUser": 2
33+
"runAsUser": 2,
34+
"runAsNonRoot": true,
3435
{% endif %}
3536
},
3637
"serviceAccountName": "prometheus-sa",

installers/olm/postgresoperator.csv.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ spec:
200200
vendor: crunchydata
201201
spec:
202202
serviceAccountName: postgres-operator
203+
securityContext:
204+
runAsNonRoot: true
203205
containers:
204206
- name: apiserver
205207
image: '${PGO_IMAGE_PREFIX}/pgo-apiserver:${PGO_IMAGE_TAG}'

0 commit comments

Comments
 (0)