Description
AppArmor restricts file and network access for Linux containers. If a profile is omitted, check node support and which profile the runtime actually applies.
Potential impact
An overly permissive profile can allow unnecessary access. An unsupported or invalid profile can prevent the Pod from starting.
Remediation
On a supported Kubernetes API, set securityContext.appArmorProfile.type to RuntimeDefault. For custom rules, review the Localhost profile and load it on every node eligible to run the Pod. Check the profile applied to the running container and test normal operations.
Examples
The excerpts use the annotation format from before Kubernetes 1.30. For hello, dummy is invalid and can cause startup to be rejected. runtime/default requests the runtime’s default profile.
Before
apiVersion: v1
kind: Pod
metadata:
name: hello-apparmor
annotations:
container.apparmor.security.beta.kubernetes.io/hello: dummy
spec:
containers:
- name: hello
image: busybox
command: ["sh", "-c", "sleep 1h"]
After
apiVersion: v1
kind: Pod
metadata:
name: hello-apparmor
annotations:
container.apparmor.security.beta.kubernetes.io/hello: runtime/default
spec:
containers:
- name: hello
image: busybox
command: ["sh", "-c", "sleep 1h"]