File tree Expand file tree Collapse file tree 11 files changed +101
-2
lines changed
controller/postgrescluster
testing/kuttl/e2e/security-context Expand file tree Collapse file tree 11 files changed +101
-2
lines changed Original file line number Diff line number Diff line change 38
38
allowPrivilegeEscalation : false
39
39
readOnlyRootFilesystem : true
40
40
runAsNonRoot : true
41
+ seccompProfile :
42
+ type : RuntimeDefault
41
43
serviceAccountName : pgo
Original file line number Diff line number Diff line change @@ -563,6 +563,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) {
563
563
privileged: false
564
564
readOnlyRootFilesystem: true
565
565
runAsNonRoot: true
566
+ seccompProfile:
567
+ type: RuntimeDefault
566
568
volumeMounts:
567
569
- mountPath: /etc/pgbackrest/server
568
570
name: pgbackrest-server
@@ -610,6 +612,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) {
610
612
privileged: false
611
613
readOnlyRootFilesystem: true
612
614
runAsNonRoot: true
615
+ seccompProfile:
616
+ type: RuntimeDefault
613
617
volumeMounts:
614
618
- mountPath: /etc/pgbackrest/server
615
619
name: pgbackrest-server
@@ -665,6 +669,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) {
665
669
privileged: false
666
670
readOnlyRootFilesystem: true
667
671
runAsNonRoot: true
672
+ seccompProfile:
673
+ type: RuntimeDefault
668
674
volumeMounts:
669
675
- mountPath: /etc/pgbackrest/server
670
676
name: pgbackrest-server
@@ -712,6 +718,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) {
712
718
privileged: false
713
719
readOnlyRootFilesystem: true
714
720
runAsNonRoot: true
721
+ seccompProfile:
722
+ type: RuntimeDefault
715
723
volumeMounts:
716
724
- mountPath: /etc/pgbackrest/server
717
725
name: pgbackrest-server
Original file line number Diff line number Diff line change @@ -2504,6 +2504,8 @@ containers:
2504
2504
privileged: false
2505
2505
readOnlyRootFilesystem: true
2506
2506
runAsNonRoot: true
2507
+ seccompProfile:
2508
+ type: RuntimeDefault
2507
2509
volumeMounts:
2508
2510
- mountPath: /etc/pgbackrest/conf.d
2509
2511
name: pgbackrest-config
Original file line number Diff line number Diff line change @@ -991,6 +991,8 @@ containers:
991
991
privileged: false
992
992
readOnlyRootFilesystem: true
993
993
runAsNonRoot: true
994
+ seccompProfile:
995
+ type: RuntimeDefault
994
996
terminationMessagePath: /dev/termination-log
995
997
terminationMessagePolicy: File
996
998
volumeMounts:
@@ -1044,6 +1046,8 @@ containers:
1044
1046
privileged: false
1045
1047
readOnlyRootFilesystem: true
1046
1048
runAsNonRoot: true
1049
+ seccompProfile:
1050
+ type: RuntimeDefault
1047
1051
terminationMessagePath: /dev/termination-log
1048
1052
terminationMessagePolicy: File
1049
1053
volumeMounts:
@@ -1099,6 +1103,8 @@ containers:
1099
1103
privileged: false
1100
1104
readOnlyRootFilesystem: true
1101
1105
runAsNonRoot: true
1106
+ seccompProfile:
1107
+ type: RuntimeDefault
1102
1108
terminationMessagePath: /dev/termination-log
1103
1109
terminationMessagePolicy: File
1104
1110
volumeMounts:
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ import (
20
20
)
21
21
22
22
// RestrictedPodSecurityContext returns a v1.PodSecurityContext with safe defaults.
23
+ // Note: All current containers have security context set by `RestrictedSecurityContext`
24
+ // which has recommended limits; if more pods/containers are added
25
+ // make sure to set the SC on the container
23
26
// See https://docs.k8s.io/concepts/security/pod-security-standards/
24
27
func RestrictedPodSecurityContext () * corev1.PodSecurityContext {
25
28
return & corev1.PodSecurityContext {
@@ -43,5 +46,12 @@ func RestrictedSecurityContext() *corev1.SecurityContext {
43
46
44
47
// Fail to start the container if its image runs as UID 0 (root).
45
48
RunAsNonRoot : Bool (true ),
49
+
50
+ // Restrict syscalls with RuntimeDefault seccomp.
51
+ // Set this on the container-level to avoid interfering
52
+ // with sidecars and injected containers.
53
+ SeccompProfile : & corev1.SeccompProfile {
54
+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
55
+ },
46
56
}
47
57
}
Original file line number Diff line number Diff line change @@ -97,8 +97,11 @@ func TestRestrictedSecurityContext(t *testing.T) {
97
97
"Containers must be required to run as non-root users." )
98
98
}
99
99
100
- assert .Assert (t , sc .SeccompProfile == nil ,
101
- "The RuntimeDefault seccomp profile must be required, or allow specific additional profiles." )
100
+ if assert .Check (t , sc .SeccompProfile != nil ) {
101
+ assert .Assert (t , sc .SeccompProfile .Type == "RuntimeDefault" ,
102
+ "Seccomp profile must be explicitly set to one of the allowed values." )
103
+ }
104
+
102
105
})
103
106
104
107
if assert .Check (t , sc .ReadOnlyRootFilesystem != nil ) {
Original file line number Diff line number Diff line change @@ -241,6 +241,8 @@ containers:
241
241
privileged: false
242
242
readOnlyRootFilesystem: true
243
243
runAsNonRoot: true
244
+ seccompProfile:
245
+ type: RuntimeDefault
244
246
volumeMounts:
245
247
- mountPath: /etc/pgadmin
246
248
name: pgadmin-startup
@@ -278,6 +280,8 @@ initContainers:
278
280
privileged: false
279
281
readOnlyRootFilesystem: true
280
282
runAsNonRoot: true
283
+ seccompProfile:
284
+ type: RuntimeDefault
281
285
volumeMounts:
282
286
- mountPath: /etc/pgadmin
283
287
name: pgadmin-startup
@@ -473,6 +477,8 @@ containers:
473
477
privileged: false
474
478
readOnlyRootFilesystem: true
475
479
runAsNonRoot: true
480
+ seccompProfile:
481
+ type: RuntimeDefault
476
482
volumeMounts:
477
483
- mountPath: /etc/pgadmin
478
484
name: pgadmin-startup
@@ -514,6 +520,8 @@ initContainers:
514
520
privileged: false
515
521
readOnlyRootFilesystem: true
516
522
runAsNonRoot: true
523
+ seccompProfile:
524
+ type: RuntimeDefault
517
525
volumeMounts:
518
526
- mountPath: /etc/pgadmin
519
527
name: pgadmin-startup
Original file line number Diff line number Diff line change @@ -571,6 +571,8 @@ func TestAddServerToInstancePod(t *testing.T) {
571
571
privileged: false
572
572
readOnlyRootFilesystem: true
573
573
runAsNonRoot: true
574
+ seccompProfile:
575
+ type: RuntimeDefault
574
576
volumeMounts:
575
577
- mountPath: /etc/pgbackrest/server
576
578
name: pgbackrest-server
@@ -617,6 +619,8 @@ func TestAddServerToInstancePod(t *testing.T) {
617
619
privileged: false
618
620
readOnlyRootFilesystem: true
619
621
runAsNonRoot: true
622
+ seccompProfile:
623
+ type: RuntimeDefault
620
624
volumeMounts:
621
625
- mountPath: /etc/pgbackrest/server
622
626
name: pgbackrest-server
@@ -701,6 +705,8 @@ func TestAddServerToRepoPod(t *testing.T) {
701
705
privileged: false
702
706
readOnlyRootFilesystem: true
703
707
runAsNonRoot: true
708
+ seccompProfile:
709
+ type: RuntimeDefault
704
710
volumeMounts:
705
711
- mountPath: /etc/pgbackrest/server
706
712
name: pgbackrest-server
@@ -743,6 +749,8 @@ func TestAddServerToRepoPod(t *testing.T) {
743
749
privileged: false
744
750
readOnlyRootFilesystem: true
745
751
runAsNonRoot: true
752
+ seccompProfile:
753
+ type: RuntimeDefault
746
754
volumeMounts:
747
755
- mountPath: /etc/pgbackrest/server
748
756
name: pgbackrest-server
Original file line number Diff line number Diff line change @@ -141,6 +141,8 @@ containers:
141
141
privileged: false
142
142
readOnlyRootFilesystem: true
143
143
runAsNonRoot: true
144
+ seccompProfile:
145
+ type: RuntimeDefault
144
146
volumeMounts:
145
147
- mountPath: /etc/pgbouncer
146
148
name: pgbouncer-config
@@ -169,6 +171,8 @@ containers:
169
171
privileged: false
170
172
readOnlyRootFilesystem: true
171
173
runAsNonRoot: true
174
+ seccompProfile:
175
+ type: RuntimeDefault
172
176
volumeMounts:
173
177
- mountPath: /etc/pgbouncer
174
178
name: pgbouncer-config
@@ -245,6 +249,8 @@ containers:
245
249
privileged: false
246
250
readOnlyRootFilesystem: true
247
251
runAsNonRoot: true
252
+ seccompProfile:
253
+ type: RuntimeDefault
248
254
volumeMounts:
249
255
- mountPath: /etc/pgbouncer
250
256
name: pgbouncer-config
@@ -278,6 +284,8 @@ containers:
278
284
privileged: false
279
285
readOnlyRootFilesystem: true
280
286
runAsNonRoot: true
287
+ seccompProfile:
288
+ type: RuntimeDefault
281
289
volumeMounts:
282
290
- mountPath: /etc/pgbouncer
283
291
name: pgbouncer-config
@@ -345,6 +353,8 @@ containers:
345
353
privileged: false
346
354
readOnlyRootFilesystem: true
347
355
runAsNonRoot: true
356
+ seccompProfile:
357
+ type: RuntimeDefault
348
358
volumeMounts:
349
359
- mountPath: /etc/pgbouncer
350
360
name: pgbouncer-config
@@ -377,6 +387,8 @@ containers:
377
387
privileged: false
378
388
readOnlyRootFilesystem: true
379
389
runAsNonRoot: true
390
+ seccompProfile:
391
+ type: RuntimeDefault
380
392
volumeMounts:
381
393
- mountPath: /etc/pgbouncer
382
394
name: pgbouncer-config
Original file line number Diff line number Diff line change @@ -143,6 +143,8 @@ containers:
143
143
privileged: false
144
144
readOnlyRootFilesystem: true
145
145
runAsNonRoot: true
146
+ seccompProfile:
147
+ type: RuntimeDefault
146
148
volumeMounts:
147
149
- mountPath: /pgconf/tls
148
150
name: cert-volume
@@ -181,6 +183,8 @@ containers:
181
183
privileged: false
182
184
readOnlyRootFilesystem: true
183
185
runAsNonRoot: true
186
+ seccompProfile:
187
+ type: RuntimeDefault
184
188
volumeMounts:
185
189
- mountPath: /pgconf/tls
186
190
name: cert-volume
@@ -247,6 +251,8 @@ initContainers:
247
251
privileged: false
248
252
readOnlyRootFilesystem: true
249
253
runAsNonRoot: true
254
+ seccompProfile:
255
+ type: RuntimeDefault
250
256
volumeMounts:
251
257
- mountPath: /pgconf/tls
252
258
name: cert-volume
You can’t perform that action at this time.
0 commit comments