Skip to content

apparmor profile not found: profile missing on the pod's node

Securitytested on Kubernetes v1.37.1, containerd v2.4.2

A Localhost profile in the securityContext refers to an AppArmor profile in the node's kernel. The API server doesn't check this: the pod is accepted and scheduled. Only containerd notices that the profile is missing when it creates the container.

Symptom

NAME      READY   STATUS                 RESTARTS   AGE
aa-miss   0/1     CreateContainerError   0          15s

The status is CreateContainerError, not CreateContainerConfigError: the runtime can't create the container.

Diagnosis

The pod's events name the missing profile.

k describe pod aa-miss | grep -m1 'Error:'
  ... Error: failed to get container spec opts: failed to generate apparmor spec opts:
apparmor profile not found cks-gibtsnicht

Causes

NodeProfile not loaded on this node

AppArmor profiles live in each node's kernel. If the profile is loaded on one worker only and the pod lands on another, it is missing there.

localhostProfileWrong name in the pod

The pod names the name after profile in the profile file, not the file name. A typo in localhostProfile leads to the same error.

securityContext:
  appArmorProfile:
    type: Localhost
    localhostProfile: cks-deny-write

Fix

Load the profile on every node the pod can run on and check with aa-status. -r replaces a loaded profile, -C loads it in complain mode. Whatever is in /etc/apparmor.d/ is loaded again when the node boots.
sudo apparmor_parser -r /etc/apparmor.d/cks-deny-write
sudo aa-status | grep -E 'profiles are in enforce|cks'
25 profiles are in enforce mode.
   cks-deny-write
▶
Break it yourself and find it – free
CKS hands-on, day 8: load AppArmor and seccomp profiles, bind them to pods and find violations in the kernel log.
Go to day 8 →

FAQ

Why don't I see any apparmor="DENIED" lines in the kernel log?

Explicit deny rules are silent. Only with audit in front (audit deny) does the kernel log the violations.

Does the old annotation still work?

The API server translates it into the appArmorProfile field but warns that it is deprecated since v1.30. New manifests use only the field.

Related error patterns

More