Apparmor

Step 0: Install Apparmor

sudo apt install apparmor-easyprof apparmor-notify apparmor-utils certspotter

Step 1: Lets Create a Simple Apparmor Profile.

Ensure this profile should be available in the system where ever the pod with apparmor annotation is running

sudo apparmor_parser -q <<EOF
#include <tunables/global>

profile k8s-apparmor-example-deny-write flags=(attach_disconnected) {
  #include <abstractions/base>

  file,

  # Deny all file writes.
  deny /** w,
}
EOF

Step 2: Verify the status of the profile:

sudo aa-status

Step 3: Sample YAML File based on Host PID:

mkdir apparmor && cd apparmor

Step 4: Apply the Pod Manifest file

Verify if the Pod is running or not. If you see the Pod in "Blocked" State, identify why the pod is blocked.

If the Apparmor profile is not present in the Worker node on which the pod is running, the pod go to blocked state.

In Case if your pod is running then verify the logs of pod

Step 5: Verification Stage

Inside the Pod Shell, run the following

You should get permission denied Error, when you run the above command.

List the Apparmor Profiles

Remove the Apparmore Profile

Disbale Apparmor

Last updated

Was this helpful?