Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 108/ 160
06. Security, RBAC & Governance

Seccomp & AppArmor Profiles in Pod Specs

Attach seccomp and AppArmor profiles to constrain syscalls and file access.

Advancedseccomp · AppArmor · Profiles3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

seccomp is a doorman rejecting disallowed system-call requests, while AppArmor is a room-access guard controlling files and privileges. The simple Kubernetes rule is: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.

Think of it like…

seccomp is a doorman rejecting disallowed system-call requests, while AppArmor is a room-access guard controlling files and privileges.

Where you’ve seen it

During an access review, the security engineer runs kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status. Expected evidence: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node. If the run instead shows this symptom, stop and restore the last known state: A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup.

Words you’ll hear

seccomp
For this lesson, seccomp is the controlling idea: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.
AppArmor
AppArmor is the checkpoint; run kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status and inspect the owner chain. A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup.
Profiles
Profiles is the outcome to preserve; the cost is explicit: Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost.
Verification evidence
The evidence command is kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status. It connects the declaration to this behavior: Attach seccomp and AppArmor profiles to constrain syscalls and file access.

Visual diagram

Loading interactive diagram

Theory & deep dive

How seccomp reaches the intended state

Attach seccomp and AppArmor profiles to constrain syscalls and file access. Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.

The concrete checkpoint is kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status; compare the seccomp owner, AppArmor state, and Profiles outcome instead of treating YAML acceptance as proof.

Verify AppArmor, not only object creation

Run kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status after the change and correlate the result with Events and the owning object. Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.

Key takeaway: seccomp is implemented only when this invariant remains observable: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.

AppArmor: failure boundary and production cost

A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup. The prerequisite contract is concrete: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.

Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost. A safe design limits blast radius, records the last good configuration, and uses kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status as a deterministic rollback checkpoint.

Recover from AppArmor drift

Capture the current state with kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup.

Key takeaway: Accept the trade-off consciously: Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost.

How it works, step by step

Step 1 of 4
Identity owner

1. Model the trust boundary

Name the identity, action, resource, and trust boundary before choosing a control: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.

seccomp contract → owned state
Key numbers at this step
Goal
Attach seccomp and AppArmor profiles to constrain syscalls and file access.
Owner
seccomp

When to use it & trade-offs

What it is

Attach seccomp and AppArmor profiles to constrain syscalls and file access. Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.

Why it matters: A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup. The invariant at risk is specific: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node. The quickest fact check before changing the design is kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status.

When to reach for it

  • Use seccomp to enforce this invariant: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.
  • Use AppArmor evidence from kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status in reviews and incident timelines. Attach seccomp and AppArmor profiles to constrain syscalls and file access.
  • Choose the hosted security service route only when this cost is justified by governance or scale: Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost.

When to avoid or be careful

  • Avoid assuming seccomp is complete after YAML submission; the required behavior is concrete: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.
  • Avoid treating the next symptom as random; check the owner and state with kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status first: A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup.
  • Avoid adopting a heavier platform wrapper before measuring its cost: Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost.

Native, manual, and managed paths for seccomp

Admission and least privilege
Best for: Attach seccomp and AppArmor profiles to constrain syscalls and file access. A concrete incident check is kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status.

Strengths: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.

Watch out: Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost. Recovery must also recognize this signal: A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup.

Runtime-only detection
Best for: Quickly testing the AppArmor assumption with kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status; the expected invariant is: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.

Strengths: kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike seccomp, it does not make this symptom self-documenting: A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup.

Hosted security service
Best for: Teams that need Profiles integrated with guardrails; the evidence path is kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.

Watch out: The added platform ownership buys value at this cost: Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.
  • Trace seccomp to Profiles through AppArmor; the invariant is: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.
  • Recognize the symptom: A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup.
  • Justify the cost: Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost.
  • Verify with kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status instead of only inspecting YAML.

Benchmarks & rules of thumb

2 -
kernel policy mechanisms: seccomp and AppArmor
1 -
profile name must exist on a node when using Localhost or AppArmor
0 -
RBAC permission change is performed by these profiles

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the seccomp owner contract: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node.
  • Ignoring this telltale condition leads to unrelated changes: A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup.
  • Repeating kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status without an owner for remediation wastes retry cost. Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node?
  • Which owner object, logs, and Events would you inspect for this symptom-A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup-?
  • At what threshold would this cost become unacceptable: Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost?
Interview tip: Interview sequence: state the invariant, run kubectl get pod hardened -o jsonpath='{.spec.securityContext.seccompProfile}'; kubectl exec hardened -- grep -E 'Seccomp|NoNewPrivs' /proc/self/status, name the failure, then justify the cost. Invariant: Seccomp filters Linux system calls through RuntimeDefault or a local profile, and AppArmor mediates file and capability behavior under a named profile loaded on each node. Failure: A RuntimeDefault profile is not identical across runtimes, and a Localhost seccomp or AppArmor profile missing on a node can stop the container before startup. Cost: Kernel-level policies defend containers beyond RBAC, but profile debugging, distro support, and node rollout alignment add operational cost.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Seccomp & AppArmor Profiles in Pod Specs with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
SecurityContext: runAsNonRoot, readOnlyRootFilesystem, Dropping Capabilities
Next topic
Policy-as-Code with Kyverno