@@ -419,6 +419,56 @@ securityContext:
419
419
localhostProfile: my-profiles/profile-allow.json
420
420
` ` `
421
421
422
+ # # Set the AppArmor Profile for a Container
423
+
424
+ To set the AppArmor profile for a Container, include the `appArmorProfile` field
425
+ in the `securityContext` section of your Container. The `appArmorProfile` field
426
+ is a
427
+ [AppArmorProfile](/docs/reference/generated/kubernetes-api/{{< param "version"
428
+ >}}/#apparmorprofile-v1-core) object consisting of `type` and `localhostProfile`.
429
+ Valid options for `type` include `RuntimeDefault`(default), `Unconfined`, and
430
+ ` Localhost` . `localhostProfile` must only be set if `type` is `Localhost`. It
431
+ indicates the name of the pre-configured profile on the node. The profile needs
432
+ to be loaded onto all nodes suitable for the Pod, since you don't know where the
433
+ pod will be scheduled.
434
+ Approaches for setting up custom profiles are discussed in
435
+ [Setting up nodes with profiles](/docs/tutorials/security/apparmor/#setting-up-nodes-with-profiles).
436
+
437
+ Note : If `containers[*].securityContext.appArmorProfile.type` is explicitly set
438
+ to `RuntimeDefault`, then the Pod will not be admitted if AppArmor is not
439
+ enabled on the Node. However if `containers[*].securityContext.appArmorProfile.type`
440
+ is not specified, then the default (which is also `RuntimeDefault`) will only
441
+ be applied if the node has AppArmor enabled. If the node has AppArmor disabled
442
+ the Pod will be admitted but the Container will not be restricted by the
443
+ ` RuntimeDefault` profile.
444
+
445
+ Here is an example that sets the AppArmor profile to the node's container runtime
446
+ default profile :
447
+
448
+ ` ` ` yaml
449
+ ...
450
+ containers:
451
+ - name: container-1
452
+ securityContext:
453
+ appArmorProfile:
454
+ type: RuntimeDefault
455
+ ` ` `
456
+
457
+ Here is an example that sets the AppArmor profile to a pre-configured profile
458
+ named `k8s-apparmor-example-deny-write` :
459
+
460
+ ` ` ` yaml
461
+ ...
462
+ containers:
463
+ - name: container-1
464
+ securityContext:
465
+ appArmorProfile:
466
+ type: Localhost
467
+ localhostProfile: k8s-apparmor-example-deny-write
468
+ ` ` `
469
+
470
+ For more details please see, [Restrict a Container's Access to Resources with AppArmor](/docs/tutorials/security/apparmor/).
471
+
422
472
# # Assign SELinux labels to a Container
423
473
424
474
To assign SELinux labels to a Container, include the `seLinuxOptions` field in
0 commit comments