@@ -74,7 +74,7 @@ application tuning. _Unsafe_ sysctls are enabled on a node-by-node basis with a
74
74
flag of the kubelet, e.g.:
75
75
76
76
``` shell
77
- $ kubelet --experimental- allowed-unsafe-sysctls \
77
+ $ kubelet --allowed-unsafe-sysctls \
78
78
' kernel.msg*,net.ipv4.route.min_pmtu' ...
79
79
```
80
80
@@ -105,20 +105,25 @@ manually by the cluster admin, either by means of the underlying Linux
105
105
distribution of the nodes (e.g. via ` /etc/sysctls.conf ` ) or using a DaemonSet
106
106
with privileged containers.
107
107
108
- The sysctl feature is an alpha API. Therefore, sysctls are set using annotations
108
+ The sysctl feature is a beta API. The sysctls are set through pod security context
109
109
on pods. They apply to all containers in the same pod.
110
110
111
- Here is an example, with different annotations for _ safe_ and _ unsafe_ sysctls:
111
+ Here is an example, (notice there is no distinction between _ safe_ and _ unsafe_ sysctls in the spec) :
112
112
113
113
``` yaml
114
114
apiVersion : v1
115
115
kind : Pod
116
116
metadata :
117
117
name : sysctl-example
118
- annotations :
119
- security.alpha.kubernetes.io/sysctls : kernel.shm_rmid_forced=1
120
- security.alpha.kubernetes.io/unsafe-sysctls : net.ipv4.route.min_pmtu=1000,kernel.msgmax=1 2 3
121
118
spec :
119
+ securityContext :
120
+ sysctls :
121
+ - name : kernel.shm_rmid_forced
122
+ value : 1
123
+ - name : net.ipv4.route.min_pmtu
124
+ value : 1000,
125
+ - name : kernel.msgmax
126
+ value : 1 2 3
122
127
...
123
128
```
124
129
{{% /capture %}}
@@ -143,13 +148,22 @@ is recommended to use
143
148
[ taints on nodes] ( /docs/concepts/configuration/taint-and-toleration/ )
144
149
to schedule those pods onto the right nodes.
145
150
146
- ## PodSecurityPolicy Annotations
151
+ ## PodSecurityPolicy
147
152
148
- The use of sysctl in pods can be controlled via annotation on the PodSecurityPolicy.
153
+ The use of sysctl in pods can be controlled through ` allowedUnsafeSysctls ` and
154
+ ` forbiddenSysctls ` fields on the PodSecurityPolicy.
149
155
150
- Sysctl annotation represents a whitelist of allowed safe and unsafe sysctls
151
- in a pod spec. It's a comma-separated list of plain sysctl names or sysctl patterns
152
- (which end in ` *`). The string `*` matches all sysctls.
156
+ By default, all safe sysctls are allowed. Currently, the whitelist of safe sysctls corresponds to:
157
+
158
+ * ` kernel.shm_rmid_forced `
159
+ * ` net.ipv4.ip_local_port_range `
160
+ * ` net.ipv4.tcp_syncookies `
161
+
162
+ Both ` allowedUnsafeSysctls ` and ` forbiddenSysctls ` are lists of plain sysctl names
163
+ or sysctl patterns (which end in ` * ` ). The string ` * ` matches all sysctls.
164
+
165
+ The ` allowedUnsafeSysctls ` field excludes sysctls from the whitelist (` * ` means no safe sysctls allowed).
166
+ Any sysctl specified by the ` forbiddenSysctls ` is on the other hand allowed (` * ` means all unsafe sysctls allowed).
153
167
154
168
Here is an example, it authorizes binding user creating pod with corresponding sysctls.
155
169
@@ -158,12 +172,12 @@ apiVersion: policy/v1beta1
158
172
kind : PodSecurityPolicy
159
173
metadata :
160
174
name : sysctl-psp
161
- annotations:
162
- security.alpha.kubernetes.io/sysctls: 'net.ipv4.route.*,kernel.msg*'
163
175
spec :
176
+ allowedUnsafeSysctls :
177
+ - kernel.msg*
178
+ forbiddenSysctls :
179
+ - kernel.shm_rmid_forced
164
180
...
165
181
```
166
182
167
183
{{% /capture %}}
168
-
169
-
0 commit comments