You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where `<container_name>` is the name of the container to apply the profile to, and `<profile_ref>`
136
-
specifies the profile to apply. The `profile_ref` can be one of:
100
+
specifies the profile to apply. The `<profile_ref>` can be one of:
137
101
138
102
* `runtime/default` to apply the runtime's default profile
139
103
* `localhost/<profile_name>` to apply the profile loaded on the host with the name `<profile_name>`
140
104
* `unconfined` to indicate that no profiles will be loaded
141
105
142
106
See the [API Reference](#api-reference) for the full details on the annotation and profile name formats.
143
107
144
-
Kubernetes AppArmor enforcement works by first checking that all the prerequisites have been
145
-
met, and then forwarding the profile selection to the container runtime for enforcement. If the
146
-
prerequisites have not been met, the Pod will be rejected, and will not run.
147
-
148
-
To verify that the profile was applied, you can look for the AppArmor security option listed in the container created event:
108
+
To verify that the profile was applied, you can check that the container's root process is
109
+
running with the correct profile by examining its proc attr:
149
110
150
111
```shell
151
-
kubectl get events | grep Created
152
-
```
153
-
```
154
-
22s 22s 1 hello-apparmor Pod spec.containers{hello} Normal Created {kubelet e2e-test-stclair-node-pool-31nt} Created container with docker id 269a53b202d3; Security:[seccomp=unconfined apparmor=k8s-apparmor-example-deny-write]
If we look at the pod events, we can see that the Pod container was created with the AppArmor
219
-
profile "k8s-apparmor-example-deny-write":
220
-
221
-
```shell
222
-
kubectl get events | grep hello-apparmor
223
-
```
224
-
```
225
-
14s 14s 1 hello-apparmor Pod Normal Scheduled {default-scheduler } Successfully assigned hello-apparmor to gke-test-default-pool-239f5d02-gyn2
226
-
14s 14s 1 hello-apparmor Pod spec.containers{hello} Normal Pulling {kubelet gke-test-default-pool-239f5d02-gyn2} pulling image "busybox"
227
-
13s 13s 1 hello-apparmor Pod spec.containers{hello} Normal Pulled {kubelet gke-test-default-pool-239f5d02-gyn2} Successfully pulled image "busybox"
228
-
13s 13s 1 hello-apparmor Pod spec.containers{hello} Normal Created {kubelet gke-test-default-pool-239f5d02-gyn2} Created container with docker id 06b6cd1c0989; Security:[seccomp=unconfined apparmor=k8s-apparmor-example-deny-write]
229
-
13s 13s 1 hello-apparmor Pod spec.containers{hello} Normal Started {kubelet gke-test-default-pool-239f5d02-gyn2} Started container with docker id 06b6cd1c0989
168
+
kubectl create -f hello-apparmor.yaml
230
169
```
231
170
232
-
We can verify that the container is actually running with that profile by checking its procattr:
171
+
You can verify that the container is actually running with that profile by checking `/proc/1/attr/current`:
23s 23s 1 {default-scheduler } Normal Scheduled Successfully assigned hello-apparmor-2 to e2e-test-stclair-node-pool-t1f5
321
-
23s 23s 1 {kubelet e2e-test-stclair-node-pool-t1f5} Warning AppArmor Cannot enforce AppArmor: profile "k8s-apparmor-example-allow-write" is not loaded
228
+
Type Reason Age From Message
229
+
---- ------ ---- ---- -------
230
+
Normal Scheduled 10s default-scheduler Successfully assigned default/hello-apparmor to gke-test-default-pool-239f5d02-x1kf
231
+
Normal Pulled 8s kubelet Successfully pulled image "busybox:1.28" in 370.157088ms (370.172701ms including waiting)
232
+
Normal Pulling 7s (x2 over 9s) kubelet Pulling image "busybox:1.28"
233
+
Warning Failed 7s (x2 over 8s) kubelet Error: failed to get container spec opts: failed to generate apparmor spec opts: apparmor profile not found k8s-apparmor-example-allow-write
234
+
Normal Pulled 7s kubelet Successfully pulled image "busybox:1.28" in 90.980331ms (91.005869ms including waiting)
322
235
```
323
236
324
-
Note the pod status is Pending, with a helpful error message: `Pod Cannot enforce AppArmor: profile
325
-
"k8s-apparmor-example-allow-write" is not loaded`. An event was also recorded with the same message.
237
+
An Event provides the error message with the reason, the specific wording is runtime-dependent:
238
+
```
239
+
Warning Failed 7s (x2 over 8s) kubelet Error: failed to get container spec opts: failed to generate apparmor spec opts: apparmor profile not found
240
+
```
326
241
327
242
## Administration
328
243
329
-
### Setting up nodes with profiles
244
+
### Setting up Nodes with profiles
330
245
331
-
Kubernetes does not currently provide any native mechanisms for loading AppArmor profiles onto
332
-
nodes. There are lots of ways to set up the profiles though, such as:
246
+
Kubernetes does not currently provide any built-in mechanisms for loading AppArmor profiles onto
247
+
Nodes. Profiles can be loaded through custom infrastructure or tools like the
0 commit comments