Skip to content

Commit 4f11f83

Browse files
committed
AppArmor v1.30 docs update
1 parent 3b6274d commit 4f11f83

File tree

8 files changed

+67
-51
lines changed

8 files changed

+67
-51
lines changed

content/en/docs/concepts/security/cloud-native-security.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ To protect your compute at runtime, you can:
143143
Pods with different trust contexts are run on separate sets of nodes.
144144
1. Use a {{< glossary_tooltip text="container runtime" term_id="container-runtime" >}}
145145
that provides security restrictions.
146-
1. On Linux nodes, use a Linux security module such as [AppArmor](/docs/tutorials/security/apparmor/) (beta)
146+
1. On Linux nodes, use a Linux security module such as [AppArmor](/docs/tutorials/security/apparmor/)
147147
or [seccomp](/docs/tutorials/security/seccomp/).
148148

149149
### Runtime protection: storage {#protection-runtime-storage}
@@ -223,4 +223,3 @@ logs are both tamper-proof and confidential.
223223
* [Network policies](/docs/concepts/services-networking/network-policies/) for Pods
224224
* [Pod security standards](/docs/concepts/security/pod-security-standards/)
225225
* [RuntimeClasses](/docs/concepts/containers/runtime-class)
226-

content/en/docs/concepts/security/pod-security-admission.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ current policy level:
121121
- Any metadata updates **except** changes to the seccomp or AppArmor annotations:
122122
- `seccomp.security.alpha.kubernetes.io/pod` (deprecated)
123123
- `container.seccomp.security.alpha.kubernetes.io/*` (deprecated)
124-
- `container.apparmor.security.beta.kubernetes.io/*`
124+
- `container.apparmor.security.beta.kubernetes.io/*` (deprecated)
125125
- Valid updates to `.spec.activeDeadlineSeconds`
126126
- Valid updates to `.spec.tolerations`
127127

content/en/docs/concepts/security/pod-security-standards.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,21 @@ fail validation.
170170
<tr>
171171
<td style="white-space: nowrap">AppArmor</td>
172172
<td>
173-
<p>On supported hosts, the <code>runtime/default</code> AppArmor profile is applied by default. The baseline policy should prevent overriding or disabling the default AppArmor profile, or restrict overrides to an allowed set of profiles.</p>
173+
<p>On supported hosts, the <code>RuntimeDefault</code> AppArmor profile is applied by default. The baseline policy should prevent overriding or disabling the default AppArmor profile, or restrict overrides to an allowed set of profiles.</p>
174174
<p><strong>Restricted Fields</strong></p>
175+
<ul>
176+
<li><code>spec.securityContext.appArmorProfile.type</code></li>
177+
<li><code>spec.containers[*].securityContext.appArmorProfile.type</code></li>
178+
<li><code>spec.initContainers[*].securityContext.appArmorProfile.type</code></li>
179+
<li><code>spec.ephemeralContainers[*].securityContext.appArmorProfile.type</code></li>
180+
</ul>
181+
<p><strong>Allowed Values</strong></p>
182+
<ul>
183+
<li>Undefined/nil</li>
184+
<li><code>RuntimeDefault</code></li>
185+
<li><code>Localhost</code></li>
186+
</ul>
187+
<hr />
175188
<ul>
176189
<li><code>metadata.annotations["container.apparmor.security.beta.kubernetes.io/*"]</code></li>
177190
</ul>
@@ -532,4 +545,3 @@ kernel. This allows for workloads requiring heightened permissions to still be i
532545

533546
Additionally, the protection of sandboxed workloads is highly dependent on the method of
534547
sandboxing. As such, no single recommended profile is recommended for all sandboxed workloads.
535-

content/en/docs/concepts/security/security-checklist.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ Seccomp is only available on Linux nodes.
177177

178178
#### AppArmor
179179

180-
[AppArmor](https://apparmor.net/) is a Linux kernel security module that can
180+
[AppArmor](/docs/tutorials/security/apparmor/) is a Linux kernel security module that can
181181
provide an easy way to implement Mandatory Access Control (MAC) and better
182-
auditing through system logs. To [enable AppArmor in Kubernetes](/docs/tutorials/security/apparmor/),
183-
at least version 1.4 is required. Like seccomp, AppArmor is also configured
182+
auditing through system logs. A default AppArmor profile is enforced on nodes that support it, or a custom profile can be configured.
183+
Like seccomp, AppArmor is also configured
184184
through profiles, where each profile is either running in enforcing mode, which
185185
blocks access to disallowed resources or complain mode, which only reports
186186
violations. AppArmor profiles are enforced on a per-container basis, with an

content/en/docs/reference/labels-annotations-taints/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ which is used by Kustomize and similar third-party tools.
300300
For example, Kustomize removes objects with this annotation from its final build output.
301301

302302

303-
### container.apparmor.security.beta.kubernetes.io/* (beta) {#container-apparmor-security-beta-kubernetes-io}
303+
### container.apparmor.security.beta.kubernetes.io/* (deprecated) {#container-apparmor-security-beta-kubernetes-io}
304304

305305
Type: Annotation
306306

@@ -309,7 +309,7 @@ Example: `container.apparmor.security.beta.kubernetes.io/my-container: my-custom
309309
Used on: Pods
310310

311311
This annotation allows you to specify the AppArmor security profile for a container within a
312-
Kubernetes pod.
312+
Kubernetes pod. As of Kubernetes v1.30, this should be set with the `appArmorProfile` field instead.
313313
To learn more, see the [AppArmor](/docs/tutorials/security/apparmor/) tutorial.
314314
The tutorial illustrates using AppArmor to restrict a container's abilities and access.
315315

content/en/docs/tasks/debug/debug-cluster/_index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ status:
203203
type: PIDPressure
204204
- lastHeartbeatTime: "2022-02-17T22:20:15Z"
205205
lastTransitionTime: "2022-02-17T22:15:15Z"
206-
message: kubelet is posting ready status. AppArmor enabled
206+
message: kubelet is posting ready status
207207
reason: KubeletReady
208208
status: "True"
209209
type: Ready
@@ -330,4 +330,3 @@ This is an incomplete list of things that could go wrong, and how to adjust your
330330
* Use `crictl` to [debug Kubernetes nodes](/docs/tasks/debug/debug-cluster/crictl/)
331331
* Get more information about [Kubernetes auditing](/docs/tasks/debug/debug-cluster/audit/)
332332
* Use `telepresence` to [develop and debug services locally](/docs/tasks/debug/debug-cluster/local-debugging/)
333-

content/en/docs/tutorials/security/apparmor.md

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ weight: 30
88

99
<!-- overview -->
1010

11-
{{< feature-state for_k8s_version="v1.4" state="beta" >}}
11+
{{< feature-state feature_gate_name="AppArmor" >}}
1212

1313

1414
[AppArmor](https://apparmor.net/) is a Linux kernel security module that supplements the standard Linux user and group based
@@ -54,7 +54,7 @@ Nodes before proceeding:
5454
Y
5555
```
5656

57-
The Kubelet verifies that AppArmor is enabled on the host before admitting a pod with AppArmor
57+
The kubelet verifies that AppArmor is enabled on the host before admitting a pod with AppArmor
5858
explicitly configured.
5959

6060
3. Container runtime supports AppArmor -- All common Kubernetes-supported container
@@ -64,7 +64,7 @@ Nodes before proceeding:
6464

6565
4. Profile is loaded -- AppArmor is applied to a Pod by specifying an AppArmor profile that each
6666
container should be run with. If any of the specified profiles are not loaded in the
67-
kernel, the Kubelet will reject the Pod. You can view which profiles are loaded on a
67+
kernel, the kubelet will reject the Pod. You can view which profiles are loaded on a
6868
node by checking the `/sys/kernel/security/apparmor/profiles` file. For example:
6969

7070
```shell
@@ -85,25 +85,26 @@ Nodes before proceeding:
8585
## Securing a Pod
8686

8787
{{< note >}}
88-
AppArmor is currently in beta, so options are specified as annotations. Once support graduates to
89-
general availability, the annotations will be replaced with first-class fields.
88+
Prior to Kubernetes v1.30, AppArmor was specified through annotations. Use the documentation version
89+
selector to view the documentation with this deprecated API.
9090
{{< /note >}}
9191

92-
AppArmor profiles are specified *per-container*. To specify the AppArmor profile to run a Pod
93-
container with, add an annotation to the Pod's metadata:
92+
AppArmor profiles can be specified at the pod level or container level. The container AppArmor
93+
profile takes precedence over the pod profile.
9494

9595
```yaml
96-
container.apparmor.security.beta.kubernetes.io/<container_name>: <profile_ref>
96+
securityContext:
97+
appArmorProfile:
98+
type: <profile_type>
9799
```
98100
99-
Where `<container_name>` is the name of the container to apply the profile to, and `<profile_ref>`
100-
specifies the profile to apply. The `<profile_ref>` can be one of:
101+
Where `<profile_type>` is one of:
101102

102-
* `runtime/default` to apply the runtime's default profile
103-
* `localhost/<profile_name>` to apply the profile loaded on the host with the name `<profile_name>`
104-
* `unconfined` to indicate that no profiles will be loaded
103+
* `RuntimeDefault` to use the runtime's default profile
104+
* `Localhost` to use a profile loaded on the host (see below)
105+
* `Unconfined` to run without AppArmor
105106

106-
See the [API Reference](#api-reference) for the full details on the annotation and profile name formats.
107+
See the [API Reference](#api-reference) for the full details on the AppArmor profile API.
107108

108109
To verify that the profile was applied, you can check that the container's root process is
109110
running with the correct profile by examining its proc attr:
@@ -115,14 +116,14 @@ kubectl exec <pod_name> -- cat /proc/1/attr/current
115116
The output should look something like this:
116117

117118
```
118-
k8s-apparmor-example-deny-write (enforce)
119+
cri-containerd.apparmor.d (enforce)
119120
```
120121

121122
## Example
122123

123124
*This example assumes you have already set up a cluster with AppArmor support.*
124125

125-
First, load the profile you want to use onto your Nodes. This profile denies all file writes:
126+
First, load the profile you want to use onto your Nodes. This profile blocks all file write operations:
126127

127128
```
128129
#include <tunables/global>
@@ -197,9 +198,11 @@ apiVersion: v1
197198
kind: Pod
198199
metadata:
199200
name: hello-apparmor-2
200-
annotations:
201-
container.apparmor.security.beta.kubernetes.io/hello: localhost/k8s-apparmor-example-allow-write
202201
spec:
202+
securityContext:
203+
appArmorProfile:
204+
type: Localhost
205+
localhostProfile: k8s-apparmor-example-allow-write
203206
containers:
204207
- name: hello
205208
image: busybox:1.28
@@ -243,7 +246,7 @@ An Event provides the error message with the reason, the specific wording is run
243246

244247
### Setting up Nodes with profiles
245248

246-
Kubernetes does not currently provide any built-in mechanisms for loading AppArmor profiles onto
249+
Kubernetes {{< skew currentVersion >}} does not provide any built-in mechanisms for loading AppArmor profiles onto
247250
Nodes. Profiles can be loaded through custom infrastructure or tools like the
248251
[Kubernetes Security Profiles Operator](https://github.com/kubernetes-sigs/security-profiles-operator).
249252

@@ -270,29 +273,31 @@ logs or through `journalctl`. More information is provided in
270273
[AppArmor failures](https://gitlab.com/apparmor/apparmor/wikis/AppArmor_Failures).
271274

272275

273-
## API Reference
276+
## Specifying AppArmor confinement
277+
278+
{{< caution >}}
279+
Prior to Kubernetes v1.30, AppArmor was specified through annotations. Use the documentation version
280+
selector to view the documentation with this deprecated API.
281+
{{< /caution >}}
274282

275-
### Pod Annotation
283+
### AppArmor profile within security context {#appArmorProfile}
276284

277-
Specifying the profile a container will run with:
285+
You can specify the `appArmorProfile` on either a container's `securityContext` or on a Pod's
286+
`securityContext`. If the profile is set at the pod level, it will be used as the default profile
287+
for all containers in the pod (including init, sidecar, and ephemeral containers). If both a pod & container
288+
AppArmor profile are set, the container's profile will be used.
278289

279-
- **key**: `container.apparmor.security.beta.kubernetes.io/<container_name>`
280-
Where `<container_name>` matches the name of a container in the Pod.
281-
A separate profile can be specified for each container in the Pod.
282-
- **value**: a profile reference, described below
290+
An AppArmor profile has 2 fields:
283291

284-
### Profile Reference
292+
`type` _(required)_ - indicates which kind of AppArmor profile will be applied. Valid options are:
293+
- `Localhost` - a profile pre-loaded on the node (specified by `localhostProfile`).
294+
- `RuntimeDefault` - the container runtime's default profile.
295+
- `Unconfined` - no AppArmor enforcement.
285296

286-
- `runtime/default`: Refers to the default runtime profile.
287-
- Equivalent to not specifying a profile, except it still requires AppArmor to be enabled.
288-
- In practice, many container runtimes use the same OCI default profile, defined here:
289-
https://github.com/containers/common/blob/main/pkg/apparmor/apparmor_linux_template.go
290-
- `localhost/<profile_name>`: Refers to a profile loaded on the node (localhost) by name.
291-
- The possible profile names are detailed in the
292-
[core policy reference](https://gitlab.com/apparmor/apparmor/wikis/AppArmor_Core_Policy_Reference#profile-names-and-attachment-specifications).
293-
- `unconfined`: This effectively disables AppArmor on the container.
297+
`localhostProfile` - The name of a profile loaded on the node that should be used.
298+
The profile must be preconfigured on the node to work.
299+
This option must be provided if and only if the `type` is `Localhost`.
294300

295-
Any other profile reference format is invalid.
296301

297302
## {{% heading "whatsnext" %}}
298303

content/en/examples/pods/security/hello-apparmor.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ apiVersion: v1
22
kind: Pod
33
metadata:
44
name: hello-apparmor
5-
annotations:
6-
# Tell Kubernetes to apply the AppArmor profile "k8s-apparmor-example-deny-write".
7-
container.apparmor.security.beta.kubernetes.io/hello: localhost/k8s-apparmor-example-deny-write
85
spec:
6+
securityContext:
7+
appArmorProfile:
8+
type: Localhost
9+
localhostProfile: k8s-apparmor-example-deny-write
910
containers:
1011
- name: hello
1112
image: busybox:1.28

0 commit comments

Comments
 (0)