Skip to content

Commit 24cde27

Browse files
authored
Merge pull request #39103 from windsonsea/lvlpss
Fix indentations in cluster-level-pss.md
2 parents da7374b + bfc82d5 commit 24cde27

File tree

1 file changed

+145
-145
lines changed

1 file changed

+145
-145
lines changed

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

Lines changed: 145 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -41,56 +41,55 @@ that are most appropriate for your configuration, do the following:
4141

4242
1. Create a cluster with no Pod Security Standards applied:
4343

44-
```shell
45-
kind create cluster --name psa-wo-cluster-pss --image kindest/node:v1.24.0
46-
```
44+
```shell
45+
kind create cluster --name psa-wo-cluster-pss --image kindest/node:v1.24.0
46+
```
4747
The output is similar to this:
48-
```
49-
Creating cluster "psa-wo-cluster-pss" ...
50-
✓ Ensuring node image (kindest/node:v1.24.0) 🖼
51-
✓ Preparing nodes 📦
52-
✓ Writing configuration 📜
53-
✓ Starting control-plane 🕹️
54-
✓ Installing CNI 🔌
55-
✓ Installing StorageClass 💾
56-
Set kubectl context to "kind-psa-wo-cluster-pss"
57-
You can now use your cluster with:
58-
59-
kubectl cluster-info --context kind-psa-wo-cluster-pss
60-
61-
Thanks for using kind! 😊
62-
63-
```
48+
```
49+
Creating cluster "psa-wo-cluster-pss" ...
50+
✓ Ensuring node image (kindest/node:v1.24.0) 🖼
51+
✓ Preparing nodes 📦
52+
✓ Writing configuration 📜
53+
✓ Starting control-plane 🕹️
54+
✓ Installing CNI 🔌
55+
✓ Installing StorageClass 💾
56+
Set kubectl context to "kind-psa-wo-cluster-pss"
57+
You can now use your cluster with:
58+
59+
kubectl cluster-info --context kind-psa-wo-cluster-pss
60+
61+
Thanks for using kind! 😊
62+
```
6463

6564
1. Set the kubectl context to the new cluster:
6665

67-
```shell
68-
kubectl cluster-info --context kind-psa-wo-cluster-pss
69-
```
66+
```shell
67+
kubectl cluster-info --context kind-psa-wo-cluster-pss
68+
```
7069
The output is similar to this:
7170

72-
```
73-
Kubernetes control plane is running at https://127.0.0.1:61350
71+
```
72+
Kubernetes control plane is running at https://127.0.0.1:61350
7473
75-
CoreDNS is running at https://127.0.0.1:61350/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
76-
77-
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
78-
```
79-
80-
1. Get a list of namespaces in the cluster:
81-
82-
```shell
83-
kubectl get ns
84-
```
85-
The output is similar to this:
86-
```
87-
NAME STATUS AGE
88-
default Active 9m30s
89-
kube-node-lease Active 9m32s
90-
kube-public Active 9m32s
91-
kube-system Active 9m32s
92-
local-path-storage Active 9m26s
93-
```
74+
CoreDNS is running at https://127.0.0.1:61350/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
75+
76+
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
77+
```
78+
79+
1. Get a list of namespaces in the cluster:
80+
81+
```shell
82+
kubectl get ns
83+
```
84+
The output is similar to this:
85+
```
86+
NAME STATUS AGE
87+
default Active 9m30s
88+
kube-node-lease Active 9m32s
89+
kube-public Active 9m32s
90+
kube-system Active 9m32s
91+
local-path-storage Active 9m26s
92+
```
9493

9594
1. Use `--dry-run=server` to understand what happens when different Pod Security Standards
9695
are applied:
@@ -100,7 +99,7 @@ that are most appropriate for your configuration, do the following:
10099
kubectl label --dry-run=server --overwrite ns --all \
101100
pod-security.kubernetes.io/enforce=privileged
102101
```
103-
The output is similar to this:
102+
The output is similar to this:
104103
```
105104
namespace/default labeled
106105
namespace/kube-node-lease labeled
@@ -113,7 +112,7 @@ that are most appropriate for your configuration, do the following:
113112
kubectl label --dry-run=server --overwrite ns --all \
114113
pod-security.kubernetes.io/enforce=baseline
115114
```
116-
The output is similar to this:
115+
The output is similar to this:
117116
```
118117
namespace/default labeled
119118
namespace/kube-node-lease labeled
@@ -127,11 +126,11 @@ that are most appropriate for your configuration, do the following:
127126
```
128127

129128
3. Restricted
130-
```shell
129+
```shell
131130
kubectl label --dry-run=server --overwrite ns --all \
132131
pod-security.kubernetes.io/enforce=restricted
133132
```
134-
The output is similar to this:
133+
The output is similar to this:
135134
```
136135
namespace/default labeled
137136
namespace/kube-node-lease labeled
@@ -179,72 +178,72 @@ following:
179178
1. Create a configuration file that can be consumed by the Pod Security
180179
Admission Controller to implement these Pod Security Standards:
181180

182-
```
183-
mkdir -p /tmp/pss
184-
cat <<EOF > /tmp/pss/cluster-level-pss.yaml
185-
apiVersion: apiserver.config.k8s.io/v1
186-
kind: AdmissionConfiguration
187-
plugins:
188-
- name: PodSecurity
189-
configuration:
190-
apiVersion: pod-security.admission.config.k8s.io/v1
191-
kind: PodSecurityConfiguration
192-
defaults:
193-
enforce: "baseline"
194-
enforce-version: "latest"
195-
audit: "restricted"
196-
audit-version: "latest"
197-
warn: "restricted"
198-
warn-version: "latest"
199-
exemptions:
200-
usernames: []
201-
runtimeClasses: []
202-
namespaces: [kube-system]
203-
EOF
204-
```
205-
206-
{{< note >}}
207-
`pod-security.admission.config.k8s.io/v1` configuration requires v1.25+.
208-
For v1.23 and v1.24, use [v1beta1](https://v1-24.docs.kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-admission-controller/).
209-
For v1.22, use [v1alpha1](https://v1-22.docs.kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-admission-controller/).
210-
{{< /note >}}
181+
```
182+
mkdir -p /tmp/pss
183+
cat <<EOF > /tmp/pss/cluster-level-pss.yaml
184+
apiVersion: apiserver.config.k8s.io/v1
185+
kind: AdmissionConfiguration
186+
plugins:
187+
- name: PodSecurity
188+
configuration:
189+
apiVersion: pod-security.admission.config.k8s.io/v1
190+
kind: PodSecurityConfiguration
191+
defaults:
192+
enforce: "baseline"
193+
enforce-version: "latest"
194+
audit: "restricted"
195+
audit-version: "latest"
196+
warn: "restricted"
197+
warn-version: "latest"
198+
exemptions:
199+
usernames: []
200+
runtimeClasses: []
201+
namespaces: [kube-system]
202+
EOF
203+
```
204+
205+
{{< note >}}
206+
`pod-security.admission.config.k8s.io/v1` configuration requires v1.25+.
207+
For v1.23 and v1.24, use [v1beta1](https://v1-24.docs.kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-admission-controller/).
208+
For v1.22, use [v1alpha1](https://v1-22.docs.kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-admission-controller/).
209+
{{< /note >}}
211210
212211
213212
1. Configure the API server to consume this file during cluster creation:
214213
215-
```
216-
cat <<EOF > /tmp/pss/cluster-config.yaml
217-
kind: Cluster
218-
apiVersion: kind.x-k8s.io/v1alpha4
219-
nodes:
220-
- role: control-plane
221-
kubeadmConfigPatches:
222-
- |
223-
kind: ClusterConfiguration
224-
apiServer:
225-
extraArgs:
226-
admission-control-config-file: /etc/config/cluster-level-pss.yaml
227-
extraVolumes:
228-
- name: accf
229-
hostPath: /etc/config
230-
mountPath: /etc/config
231-
readOnly: false
232-
pathType: "DirectoryOrCreate"
233-
extraMounts:
234-
- hostPath: /tmp/pss
235-
containerPath: /etc/config
236-
# optional: if set, the mount is read-only.
237-
# default false
238-
readOnly: false
239-
# optional: if set, the mount needs SELinux relabeling.
240-
# default false
241-
selinuxRelabel: false
242-
# optional: set propagation mode (None, HostToContainer or Bidirectional)
243-
# see https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation
244-
# default None
245-
propagation: None
246-
EOF
247-
```
214+
```
215+
cat <<EOF > /tmp/pss/cluster-config.yaml
216+
kind: Cluster
217+
apiVersion: kind.x-k8s.io/v1alpha4
218+
nodes:
219+
- role: control-plane
220+
kubeadmConfigPatches:
221+
- |
222+
kind: ClusterConfiguration
223+
apiServer:
224+
extraArgs:
225+
admission-control-config-file: /etc/config/cluster-level-pss.yaml
226+
extraVolumes:
227+
- name: accf
228+
hostPath: /etc/config
229+
mountPath: /etc/config
230+
readOnly: false
231+
pathType: "DirectoryOrCreate"
232+
extraMounts:
233+
- hostPath: /tmp/pss
234+
containerPath: /etc/config
235+
# optional: if set, the mount is read-only.
236+
# default false
237+
readOnly: false
238+
# optional: if set, the mount needs SELinux relabeling.
239+
# default false
240+
selinuxRelabel: false
241+
# optional: set propagation mode (None, HostToContainer or Bidirectional)
242+
# see https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation
243+
# default None
244+
propagation: None
245+
EOF
246+
```
248247
249248
{{<note>}}
250249
If you use Docker Desktop with KinD on macOS, you can
@@ -256,56 +255,57 @@ following:
256255
these Pod Security Standards:
257256
258257
```shell
259-
kind create cluster --name psa-with-cluster-pss --image kindest/node:v1.24.0 --config /tmp/pss/cluster-config.yaml
258+
kind create cluster --name psa-with-cluster-pss --image kindest/node:v1.24.0 --config /tmp/pss/cluster-config.yaml
260259
```
261260
The output is similar to this:
262261
```
263-
Creating cluster "psa-with-cluster-pss" ...
264-
✓ Ensuring node image (kindest/node:v1.24.0) 🖼
265-
✓ Preparing nodes 📦
266-
✓ Writing configuration 📜
267-
✓ Starting control-plane 🕹️
268-
✓ Installing CNI 🔌
269-
✓ Installing StorageClass 💾
270-
Set kubectl context to "kind-psa-with-cluster-pss"
271-
You can now use your cluster with:
262+
Creating cluster "psa-with-cluster-pss" ...
263+
✓ Ensuring node image (kindest/node:v1.24.0) 🖼
264+
✓ Preparing nodes 📦
265+
✓ Writing configuration 📜
266+
✓ Starting control-plane 🕹️
267+
✓ Installing CNI 🔌
268+
✓ Installing StorageClass 💾
269+
Set kubectl context to "kind-psa-with-cluster-pss"
270+
You can now use your cluster with:
272271
273-
kubectl cluster-info --context kind-psa-with-cluster-pss
272+
kubectl cluster-info --context kind-psa-with-cluster-pss
274273
275-
Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂
276-
```
274+
Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂
275+
```
277276

278-
1. Point kubectl to the cluster
277+
1. Point kubectl to the cluster:
279278
```shell
280-
kubectl cluster-info --context kind-psa-with-cluster-pss
281-
```
279+
kubectl cluster-info --context kind-psa-with-cluster-pss
280+
```
282281
The output is similar to this:
283-
```
284-
Kubernetes control plane is running at https://127.0.0.1:63855
285-
CoreDNS is running at https://127.0.0.1:63855/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
282+
```
283+
Kubernetes control plane is running at https://127.0.0.1:63855
284+
285+
CoreDNS is running at https://127.0.0.1:63855/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
286286
287-
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
288-
```
287+
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
288+
```
289289
1. Create the following Pod specification for a minimal configuration in the default namespace:
290290

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-
```
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+
```
305305
1. Create the Pod in the cluster:
306306

307307
```shell
308-
kubectl apply -f /tmp/pss/nginx-pod.yaml
308+
kubectl apply -f /tmp/pss/nginx-pod.yaml
309309
```
310310
The output is similar to this:
311311
```

0 commit comments

Comments
 (0)