Skip to content

Commit 7f4c0e6

Browse files
committed
OSDOCS 6914: Updating pod examples to comply with restricted PSA (Nodes book)
1 parent f5741bc commit 7f4c0e6

File tree

33 files changed

+404
-119
lines changed

33 files changed

+404
-119
lines changed

modules/nodes-cluster-resource-configure-request-limit.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ kind: Pod
2222
metadata:
2323
name: test
2424
spec:
25+
securityContext:
26+
runAsNonRoot: true
27+
seccompProfile:
28+
type: RuntimeDefault
2529
containers:
2630
- name: test
2731
image: fedora:latest
@@ -44,6 +48,10 @@ spec:
4448
memory: 384Mi
4549
limits:
4650
memory: 512Mi
51+
securityContext:
52+
allowPrivilegeEscalation: false
53+
capabilities:
54+
drop: [ALL]
4755
----
4856
<1> Add this stanza to discover the application memory request value.
4957
<2> Add this stanza to discover the application memory limit value.

modules/nodes-cluster-resource-levels-command.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ metadata:
3131
app: guestbook
3232
tier: frontend
3333
spec:
34+
securityContext:
35+
runAsNonRoot: true
36+
seccompProfile:
37+
type: RuntimeDefault
3438
containers:
3539
- name: php-redis
3640
image: gcr.io/google-samples/gb-frontend:v4
@@ -42,6 +46,10 @@ spec:
4246
requests:
4347
cpu: 150m
4448
memory: 100Mi
49+
securityContext:
50+
allowPrivilegeEscalation: false
51+
capabilities:
52+
drop: [ALL]
4553
----
4654

4755
.. Create the cluster role:

modules/nodes-cluster-resource-levels-job.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ metadata:
8787
app: guestbook
8888
tier: frontend
8989
spec:
90+
securityContext:
91+
runAsNonRoot: true
92+
seccompProfile:
93+
type: RuntimeDefault
9094
containers:
9195
- name: php-redis
9296
image: gcr.io/google-samples/gb-frontend:v4
@@ -98,6 +102,10 @@ spec:
98102
requests:
99103
cpu: 150m
100104
memory: 100Mi
105+
securityContext:
106+
allowPrivilegeEscalation: false
107+
capabilities:
108+
drop: [ALL]
101109
----
102110

103111
.. Create the pod by running the following command:

modules/nodes-containers-downward-api-container-configmaps.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ kind: Pod
4343
metadata:
4444
name: dapi-env-test-pod
4545
spec:
46+
securityContext:
47+
runAsNonRoot: true
48+
seccompProfile:
49+
type: RuntimeDefault
4650
containers:
4751
- name: env-test-container
4852
image: gcr.io/google_containers/busybox
@@ -53,6 +57,10 @@ spec:
5357
configMapKeyRef:
5458
name: myconfigmap
5559
key: mykey
60+
securityContext:
61+
allowPrivilegeEscalation: false
62+
capabilities:
63+
drop: [ALL]
5664
restartPolicy: Always
5765
# ...
5866
----

modules/nodes-containers-downward-api-container-envars.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ kind: Pod
2424
metadata:
2525
name: dapi-env-test-pod
2626
spec:
27+
securityContext:
28+
runAsNonRoot: true
29+
seccompProfile:
30+
type: RuntimeDefault
2731
containers:
2832
- name: env-test-container
2933
image: gcr.io/google_containers/busybox
@@ -33,6 +37,10 @@ spec:
3337
value: my_value
3438
- name: MY_ENV_VAR_REF_ENV
3539
value: $(MY_EXISTING_ENV)
40+
securityContext:
41+
allowPrivilegeEscalation: false
42+
capabilities:
43+
drop: [ALL]
3644
restartPolicy: Never
3745
# ...
3846
----

modules/nodes-containers-downward-api-container-escaping.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,21 @@ kind: Pod
2323
metadata:
2424
name: dapi-env-test-pod
2525
spec:
26+
securityContext:
27+
runAsNonRoot: true
28+
seccompProfile:
29+
type: RuntimeDefault
2630
containers:
2731
- name: env-test-container
2832
image: gcr.io/google_containers/busybox
2933
command: [ "/bin/sh", "-c", "env" ]
3034
env:
3135
- name: MY_NEW_ENV
3236
value: $$(SOME_OTHER_ENV)
37+
securityContext:
38+
allowPrivilegeEscalation: false
39+
capabilities:
40+
drop: [ALL]
3341
restartPolicy: Never
3442
# ...
3543
----

modules/nodes-containers-downward-api-container-secrets.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ kind: Pod
4646
metadata:
4747
name: dapi-env-test-pod
4848
spec:
49+
securityContext:
50+
runAsNonRoot: true
51+
seccompProfile:
52+
type: RuntimeDefault
4953
containers:
5054
- name: env-test-container
5155
image: gcr.io/google_containers/busybox
@@ -56,6 +60,10 @@ spec:
5660
secretKeyRef:
5761
name: mysecret
5862
key: username
63+
securityContext:
64+
allowPrivilegeEscalation: false
65+
capabilities:
66+
drop: [ALL]
5967
restartPolicy: Never
6068
# ...
6169
----

modules/nodes-containers-downward-api-container-values-envars.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ kind: Pod
3131
metadata:
3232
name: dapi-env-test-pod
3333
spec:
34+
securityContext:
35+
runAsNonRoot: true
36+
seccompProfile:
37+
type: RuntimeDefault
3438
containers:
3539
- name: env-test-container
3640
image: gcr.io/google_containers/busybox
@@ -44,6 +48,10 @@ spec:
4448
valueFrom:
4549
fieldRef:
4650
fieldPath: metadata.namespace
51+
securityContext:
52+
allowPrivilegeEscalation: false
53+
capabilities:
54+
drop: [ALL]
4755
restartPolicy: Never
4856
# ...
4957
----

modules/nodes-containers-downward-api-container-values-plugin.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ metadata:
4040
annotation1: "345"
4141
annotation2: "456"
4242
spec:
43+
securityContext:
44+
runAsNonRoot: true
45+
seccompProfile:
46+
type: RuntimeDefault
4347
containers:
4448
- name: volume-test-container
4549
image: gcr.io/google_containers/busybox
@@ -48,6 +52,10 @@ spec:
4852
- name: podinfo
4953
mountPath: /tmp/etc
5054
readOnly: false
55+
securityContext:
56+
allowPrivilegeEscalation: false
57+
capabilities:
58+
drop: [ALL]
5159
volumes:
5260
- name: podinfo
5361
downwardAPI:

modules/nodes-containers-init-creating.adoc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,33 @@ metadata:
2323
labels:
2424
app: myapp
2525
spec:
26+
securityContext:
27+
runAsNonRoot: true
28+
seccompProfile:
29+
type: RuntimeDefault
2630
containers:
2731
- name: myapp-container
2832
image: registry.access.redhat.com/ubi9/ubi:latest
2933
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
34+
securityContext:
35+
allowPrivilegeEscalation: false
36+
capabilities:
37+
drop: [ALL]
3038
initContainers:
3139
- name: init-myservice
3240
image: registry.access.redhat.com/ubi9/ubi:latest
3341
command: ['sh', '-c', 'until getent hosts myservice; do echo waiting for myservice; sleep 2; done;']
42+
securityContext:
43+
allowPrivilegeEscalation: false
44+
capabilities:
45+
drop: [ALL]
3446
- name: init-mydb
3547
image: registry.access.redhat.com/ubi9/ubi:latest
3648
command: ['sh', '-c', 'until getent hosts mydb; do echo waiting for mydb; sleep 2; done;']
37-
# ...
49+
securityContext:
50+
allowPrivilegeEscalation: false
51+
capabilities:
52+
drop: [ALL]
3853
----
3954

4055
.. Create the pod:

0 commit comments

Comments
 (0)