Skip to content

Commit c38e5c0

Browse files
author
Tim Bannister
committed
Avoid creating local manifest for PSA tutorials
The kubectl tool includes a client for fetching manifests using HTTP, and we usually rely on that for tutorials. Switch to an approach where we don't create a manifest on the filesystem and then apply that.
1 parent 5fd1a9d commit c38e5c0

File tree

5 files changed

+25
-45
lines changed

5 files changed

+25
-45
lines changed

content/en/docs/tutorials/security/cluster-level-pss.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -286,31 +286,16 @@ following:
286286
287287
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
288288
```
289-
1. Create the following Pod specification for a minimal configuration in the default namespace:
290-
291-
```
292-
cat <<EOF > /tmp/pss/nginx-pod.yaml
293-
apiVersion: v1
294-
kind: Pod
295-
metadata:
296-
name: nginx
297-
spec:
298-
containers:
299-
- image: nginx
300-
name: nginx
301-
ports:
302-
- containerPort: 80
303-
EOF
304-
```
305-
1. Create the Pod in the cluster:
289+
1. Create a Pod in the default namespace:
306290

307291
```shell
308-
kubectl apply -f /tmp/pss/nginx-pod.yaml
292+
kubectl apply -f https://k8s.io/examples/security/example-baseline-pod.yaml
309293
```
294+
310295
The output is similar to this:
311296
```
312-
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "nginx" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "nginx" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "nginx" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "nginx" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
313-
pod/nginx created
297+
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "nginx" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "nginx" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "nginx" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "nginx" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
298+
pod/nginx created
314299
```
315300

316301
## Clean up

content/en/docs/tutorials/security/ns-level-pss.md

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,27 +109,10 @@ namespace/example created
109109

110110
## Verify the Pod Security Standards
111111

112-
1. Create a minimal pod in `example` namespace:
112+
1. Create a baseline Pod in the `example` namespace:
113113

114114
```shell
115-
cat <<EOF > /tmp/pss/nginx-pod.yaml
116-
apiVersion: v1
117-
kind: Pod
118-
metadata:
119-
name: nginx
120-
spec:
121-
containers:
122-
- image: nginx
123-
name: nginx
124-
ports:
125-
- containerPort: 80
126-
EOF
127-
```
128-
129-
1. Apply the pod spec to the cluster in `example` namespace:
130-
131-
```shell
132-
kubectl apply -n example -f /tmp/pss/nginx-pod.yaml
115+
kubectl apply -n example -f https://k8s.io/examples/security/example-baseline-pod.yaml
133116
```
134117
The output is similar to this:
135118

@@ -138,10 +121,10 @@ namespace/example created
138121
pod/nginx created
139122
```
140123

141-
1. Apply the pod spec to the cluster in `default` namespace:
124+
1. Create a baseline Pod in the `default` namespace:
142125

143126
```shell
144-
kubectl apply -n default -f /tmp/pss/nginx-pod.yaml
127+
kubectl apply -n default -f https://k8s.io/examples/security/example-baseline-pod.yaml
145128
```
146129
Output is similar to this:
147130

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: nginx
5+
spec:
6+
containers:
7+
- image: nginx
8+
name: nginx
9+
ports:
10+
- containerPort: 80

content/en/examples/security/kind-with-cluster-level-baseline-pod-security.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ kind create cluster --name psa-with-cluster-pss --image kindest/node:v1.23.0 --c
5555
kubectl cluster-info --context kind-psa-with-cluster-pss
5656
# Wait for 15 seconds (arbitrary) ServiceAccount Admission Controller to be available
5757
sleep 15
58-
cat <<EOF > /tmp/pss/nginx-pod.yaml
58+
cat <<EOF |
5959
apiVersion: v1
6060
kind: Pod
6161
metadata:
@@ -67,4 +67,4 @@ spec:
6767
ports:
6868
- containerPort: 80
6969
EOF
70-
kubectl apply -f /tmp/pss/nginx-pod.yaml
70+
kubectl apply -f -

content/en/examples/security/kind-with-namespace-level-baseline-pod-security.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ kubectl label --overwrite ns example \
1313
pod-security.kubernetes.io/warn-version=latest \
1414
pod-security.kubernetes.io/audit=restricted \
1515
pod-security.kubernetes.io/audit-version=latest
16-
cat <<EOF > /tmp/pss/nginx-pod.yaml
16+
17+
# Try running a Pod
18+
cat <<EOF |
1719
apiVersion: v1
1820
kind: Pod
1921
metadata:
@@ -25,4 +27,4 @@ spec:
2527
ports:
2628
- containerPort: 80
2729
EOF
28-
kubectl apply -n example -f /tmp/pss/nginx-pod.yaml
30+
kubectl apply -n example -f -

0 commit comments

Comments
 (0)