@@ -41,56 +41,55 @@ that are most appropriate for your configuration, do the following:
41
41
42
42
1 . Create a cluster with no Pod Security Standards applied:
43
43
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
+ ```
47
47
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
+ ```
64
63
65
64
1 . Set the kubectl context to the new cluster:
66
65
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
+ ```
70
69
The output is similar to this:
71
70
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
74
73
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
+ ```
94
93
95
94
1 . Use ` --dry-run=server ` to understand what happens when different Pod Security Standards
96
95
are applied:
@@ -100,7 +99,7 @@ that are most appropriate for your configuration, do the following:
100
99
kubectl label --dry-run=server --overwrite ns --all \
101
100
pod-security.kubernetes.io/enforce=privileged
102
101
```
103
- The output is similar to this:
102
+ The output is similar to this:
104
103
```
105
104
namespace/default labeled
106
105
namespace/kube-node-lease labeled
@@ -113,7 +112,7 @@ that are most appropriate for your configuration, do the following:
113
112
kubectl label --dry-run=server --overwrite ns --all \
114
113
pod-security.kubernetes.io/enforce=baseline
115
114
` ` `
116
- The output is similar to this:
115
+ The output is similar to this:
117
116
```
118
117
namespace/default labeled
119
118
namespace/kube-node-lease labeled
@@ -127,11 +126,11 @@ that are most appropriate for your configuration, do the following:
127
126
```
128
127
129
128
3. Restricted
130
- ` ` ` shell
129
+ ` ` ` shell
131
130
kubectl label --dry-run=server --overwrite ns --all \
132
131
pod-security.kubernetes.io/enforce=restricted
133
132
` ` `
134
- The output is similar to this:
133
+ The output is similar to this:
135
134
```
136
135
namespace/default labeled
137
136
namespace/kube-node-lease labeled
@@ -179,72 +178,72 @@ following:
179
178
1. Create a configuration file that can be consumed by the Pod Security
180
179
Admission Controller to implement these Pod Security Standards:
181
180
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 >}}
211
210
212
211
213
212
1. Configure the API server to consume this file during cluster creation:
214
213
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
+ ```
248
247
249
248
{{<note>}}
250
249
If you use Docker Desktop with KinD on macOS, you can
@@ -256,56 +255,57 @@ following:
256
255
these Pod Security Standards:
257
256
258
257
```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
260
259
```
261
260
The output is similar to this:
262
261
```
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:
272
271
273
- kubectl cluster-info --context kind-psa-with-cluster-pss
272
+ kubectl cluster-info --context kind-psa-with-cluster-pss
274
273
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
+ ```
277
276
278
- 1. Point kubectl to the cluster
277
+ 1 . Point kubectl to the cluster:
279
278
``` shell
280
- kubectl cluster-info --context kind-psa-with-cluster-pss
281
- ` ` `
279
+ kubectl cluster-info --context kind-psa-with-cluster-pss
280
+ ```
282
281
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
286
286
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
+ ```
289
289
1 . Create the following Pod specification for a minimal configuration in the default namespace:
290
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
- ` ` `
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
305
1 . Create the Pod in the cluster:
306
306
307
307
``` shell
308
- kubectl apply -f /tmp/pss/nginx-pod.yaml
308
+ kubectl apply -f /tmp/pss/nginx-pod.yaml
309
309
```
310
310
The output is similar to this:
311
311
```
0 commit comments