Restricting Kubernetes containers with seccomp and AppArmor for your clusters
Seccomp and AppArmor limit what a container process can do on the node kernel. Seccomp filters the system calls a process may make, and AppArmor restricts file paths, capabilities and some network operations through a named profile. Teams need both when containers share a node kernel and the security team wants a smaller set of kernel interfaces reachable from each workload, so that a compromised process has fewer ways to escalate. In a self-managed cluster, you set these controls per pod or container through the securityContext fields, and the Kubernetes documentation is the reference for how each field behaves.
These controls sit beside Pod Security Standards rather than replacing them. The Restricted and Baseline levels already require or limit seccomp and AppArmor settings, and Pod Security Standards are enforced per namespace by Pod Security Admission. Policy engines can go further by requiring specific profiles or blocking exceptions. Before you design the profiles, confirm which container runtime, operating system and kernel features your nodes provide, because AppArmor depends on host support and a profile that cannot load will stop a pod from starting. Also confirm the default seccomp profile your runtime ships for your Kubernetes version, since that profile becomes the baseline for every workload.
Start with RuntimeDefault for all workloads, then write custom seccomp and AppArmor profiles only for sensitive pods, such as those that handle credentials or run third-party code. Roll out in a staging namespace first and collect the denied calls and file accesses. Ask each application owner which workloads need unusual system calls, such as those used for debugging, mounting or tracing, and record each exception with its justification and an owner. Then promote the profiles namespace by namespace, and keep the test cases in Git so that a runtime or application upgrade can be checked against the same profiles before it reaches production.
Which profile type fits which workload
This table compares the four confinement options for a container: RuntimeDefault seccomp, custom Localhost seccomp profiles, AppArmor profiles, and Unconfined, plus the namespace-level Pod Security Standards that decide what is allowed. Read each row as a starting point for a workload class, then test the profile against that workload before enforcing it cluster-wide.
| Option | Use case | Operational cost | Risk |
|---|---|---|---|
| RuntimeDefault seccomp | Default for nearly all application pods, including stateless web services, workers and most databases | Low. Set once per namespace or in a mutating policy, with occasional breakage from newer syscalls to troubleshoot | Lowest residual risk among practical choices, though it still permits a broad set of syscalls |
| Custom Localhost seccomp profile | Sensitive pods that need a tightly scoped syscall allowlist, such as a payment or key-handling service | High. Profiles must be written, distributed to nodes, tested and updated with each application or base image change | Low when the allowlist is accurate; a missing syscall causes outages and an overly broad one adds little protection |
| AppArmor profile via securityContext | Nodes and workloads where the team already runs AppArmor and wants file and capability rules alongside syscall filtering | Medium to high. Profiles are loaded on each node, depend on the host OS, and must be checked after node image changes | Moderate; protection depends on the profile covering the paths and capabilities the workload actually uses |
| Unconfined | Short-lived debugging, a vendor component that has not yet been tested with a profile, or a documented exception | Low to set, but each exception needs review, an owner and an expiry date | Highest. The container runs with no seccomp filter, widening what a compromised process can reach in the kernel |
| Pod Security Standards Baseline | Namespace-level floor for general workloads where the team wants to block known privilege escalation paths | Low to medium. Enforced by the built-in Pod Security Admission controller; failures appear at admission | Blocks many common escalations but permits some settings that Restricted would refuse |
| Pod Security Standards Restricted | Namespaces for internet-facing, multi-tenant or regulated workloads that should run with the strictest defaults | Medium. Requires seccomp profiles to be set and may need changes to images that assume root or extra capabilities | Lowest of the standard levels; pods must already set a seccomp profile, so Restricted is the natural enforcement point for RuntimeDefault |
Rolling out RuntimeDefault seccomp without breaking applications
This sequence moves a cluster from workloads with no seccomp setting, or with unconfined profiles, to RuntimeDefault enforcement. Each namespace is checked in audit and warning mode before enforcement, so breakage is found in staging and in logs first.
Confirm runtime and node OS support
The platform team checks that each node's container runtime and operating system support the seccomp profile types you plan to use, and confirms with your distribution's documentation whether the kubelet applies RuntimeDefault by default. Record the answer per node pool, because mixed pools often behave differently. Done means every node pool is listed with its runtime, OS and kubelet seccomp default, and any pool you cannot confirm is flagged for follow-up before any namespace changes.
Inventory workloads and their security context
The platform team, with application owners, lists every workload by namespace and records the pod and container securityContext, including any seccompProfile set to Unconfined or Localhost, privileged containers and host namespace use. Workloads that already declare RuntimeDefault are marked as ready. Done means a single inventory exists with an owner for each workload, and the workloads that need changes are sorted by namespace so the rollout order can be set.
Set audit and warning labels on namespaces
Using the built-in Pod Security Admission controller, the platform team adds the audit and warn labels to each namespace at the Baseline or Restricted level, with enforce left unchanged. Warnings appear for new or updated pods that would fail, and audit entries are written to the API server audit log for existing pods. Check that labels were applied with a command listing namespace labels, then apply a test pod in staging and confirm that the warning text appears in the command output.
Set RuntimeDefault in workload manifests
Application owners add a seccompProfile of type RuntimeDefault to the pod-level securityContext in Helm values, Kustomize patches or raw manifests, and the change is reviewed through the normal Git workflow. After the rollout, the platform team confirms the profile appears in the running pod spec by reading the pod with a JSONPath query for the seccompProfile field. Done means the field is present on every pod in the inventory, and no pod still reports Unconfined.
Test applications in staging
The application owners run functional tests, smoke tests and the normal load pattern against the staging namespace with the new profile. The platform team watches for container start failures, restart loops, failed readiness probes and operation-not-permitted errors in application logs, and checks node kernel or audit logs for seccomp denial records. Done means each application passes its tests, no pod restarts because of the profile, and any denied syscall is either traced to a code path or added to the exception list with an owner.
Resolve exceptions with reviewed profiles
For each workload that still fails, the team chooses between changing the application, using a custom Localhost profile for that workload, or recording a time-limited exception with a named owner and a review date. A Localhost profile must exist as a file on every node where the pod can run, so the team confirms file distribution before rollout. Done means every remaining exception has a written reason, an owner, a profile source and a review date in the security register.
Enforce namespace by namespace
The platform team switches the enforce label to Baseline or Restricted one namespace at a time, starting with the lowest-risk namespace and ending with the most sensitive. After each switch, the team checks the admission events for rejected pods, confirms that expected workloads keep running, and watches the error rate on dashboards for the next full release cycle of that application. Done means the namespace enforces the chosen level, and the rollback step, removing the enforce label, has been tested on paper or in staging.
When a custom seccomp profile is worth the effort
A custom Localhost seccomp profile is worth building only for pods whose system call set is narrow, stable and well understood, such as a single-purpose service that does network I/O and reads its own configuration. For most workloads, RuntimeDefault already removes a large set of dangerous calls with little effort, and a custom profile adds maintenance that only pays off when the extra reduction matters for that workload's risk. Sensitive candidates include a privileged-adjacent sidecar, a token or key handling service, or a component that handles untrusted input and whose behavior you can enumerate. Ask the application owner to confirm the expected syscall set before deciding.
The work has three parts. First, profile real syscall use in a test environment: run the workload through its full range of functions, including startup, upgrades, health checks, backup jobs and error paths, and record what it calls. Missing a rarely used path is the most common cause of a production failure, so treat coverage as the main quality measure. Second, distribute the profile file to every node. Profiles live under the kubelet's seccomp directory, and the pod's localhostProfile value is a path relative to that directory, so the file must exist on each node at the referenced path before pods start. If a node lacks the file, the pod will not start there. Use a configuration management tool or a DaemonSet with a clear owner, and confirm the path your kubelet version expects.
The third part recurs. Every application upgrade, library change, base image change or new feature can add system calls, so the profile needs a review step in the release pipeline and a test that runs the workload under the profile. Keep the profile in version control next to the workload manifest, and record which image version it was built for. Plan for a rollback path that does not depend on the profile being current. Ask any partner quoting this work to show how profile changes are tested, distributed and reviewed, and who signs off when a release needs a new syscall.
Security and operational risks of profile rollouts
Seccomp and AppArmor profiles fail quietly when they are skipped, copied unevenly or left stale. Each card below names a risk, the control that addresses it and the check to run before and after a rollout.
Unconfined profiles left in place
A pod set to Unconfined or a namespace that was exempted during testing often stays that way after the rollout is declared finished. Control: record every exception with an owner and reason, and set RuntimeDefault as the default for new workloads. Check: query the cluster for pods whose securityContext sets seccompProfile to Unconfined or whose AppArmor annotation is missing or set to unconfined, and compare the list with the exception register.
Profile drift after application updates
A new container image can call syscalls that the profile did not allow, or the chart may change the securityContext during an upgrade. Control: keep profile references in the same Git-managed manifests as the workload and review them in every chart or image bump. Check: render the chart before each release and diff the seccompProfile and AppArmor fields against the previous version.
Pod Security StandardsProfiles that differ across nodes
Localhost seccomp profiles and AppArmor profiles must exist on the node where the pod is scheduled. A profile loaded on some nodes but not others produces pods that start on one node and fail on another. Control: distribute profiles with a daemonset or node configuration tool and label nodes by profile set. Check: confirm that every node pool in the cluster reports the same profile files and load status before scheduling enforced workloads.
Silent breakage in rare code paths
A profile that passes a smoke test can still block a syscall used only during error handling, backup jobs, log rotation or certificate reloads. The failure appears as an unexplained crash or permission error days later. Control: run the application through its full set of jobs and failure paths in staging with audit or log-only mode where the runtime supports it. Check: review denied syscall events from staging traffic and confirm each one has been reviewed before enforcement.
Init and sidecar containers skipped
Teams often set the profile on the main container and forget init containers, sidecars and ephemeral debugging containers. Each container in a pod has its own securityContext, so a gap leaves part of the pod outside the restriction. Control: include every container type in the policy checks and in the review template. Check: list all containers, init containers and sidecars per pod with their seccomp and AppArmor settings, then confirm no entry is missing or unconfined.
Exceptions without review dates
Exceptions granted for a vendor image or a legacy service rarely get revisited, and the list grows without an owner. Control: record each exception with the workload, the reason, the approving owner and a review date, and link it to the policy engine's exception list where one is used. Check: at each review, confirm that every exception still has a valid reason and that the underlying workload has not been replaced or upgraded out of the need for it.
Phases of a seccomp and AppArmor rollout move from inventory to enforcement in stages
The rollout starts with an inventory of workloads and their syscall and file needs, then splits into RuntimeDefault for most pods or a custom profile for sensitive ones. Each profile is tested in staging before enforcement through Pod Security Admission or a policy engine. Denials observed after enforcement feed back into profile changes, so a failed check returns to the testing step rather than moving forward. Check that every hand-off has an owner and a recorded exception path.
Decision path from workload inventory to enforced seccomp and AppArmor profiles.
Limits to confirm in your environment
Seccomp and AppArmor protection depends on the node OS, the container runtime, the distribution's defaults, the Kubernetes version and your policy tooling. Each item below is a dependency you should confirm with the vendor or with your own tests before you describe the cluster as hardened.
AppArmor enforcement on nodes
An AppArmor profile in the securityContext only takes effect if the node's kernel and operating system have AppArmor enabled and loaded. Some node images, minimal hardened OS builds and some non-Ubuntu distributions ship without it or with it disabled. Check each node pool, not just one node, by confirming the module is loaded and that a test pod with a deny rule is actually blocked. A pod that starts without error proves nothing about enforcement.
Pod Security StandardsDefault seccomp profile in your distribution
Confirm whether your chosen distribution sets the RuntimeDefault seccomp profile for workloads by default, or only offers it as an option. Some distributions default to Unconfined for system components or leave the kubelet setting off. Read the distribution's kubelet and runtime configuration and inspect a running pod's securityContext to see what is actually applied. Record the answer per namespace, because platform workloads often run with different settings.
Field support for your Kubernetes version
Fields for seccomp and AppArmor have moved between API locations and changed status across Kubernetes releases, so manifests that work on one minor version may be ignored or rejected on another. Find your cluster's exact minor version, check its support window on the releases page, and test the fields you use against that version in a staging cluster before you rely on them in production.
Kubernetes releasesPolicy engine behavior with these fields
If Kyverno, Gatekeeper or another admission controller enforces seccomp or AppArmor settings, confirm how it reads and mutates the securityContext fields, including the legacy annotation form and the current field form. Check whether a mutation rule can override a developer's explicit Unconfined setting, and whether audit mode reports the same results as enforce mode. Test both allowed and denied pods, plus workloads created by operators, since controllers often generate their own pod templates.
Mapping CIS Benchmark recommendations
The CIS Kubernetes Benchmark covers pod security settings, but its recommendations are written for specific configurations and may not match your distribution's file paths, kubelet flags or managed-service defaults. Map each recommendation you claim to meet to a check you ran on your cluster, record the result and any accepted deviation, and confirm the benchmark version that applies to your Kubernetes release with the benchmark publisher.
CIS Kubernetes BenchmarkQuestions teams ask before restricting containers with seccomp and AppArmor
What drives the cost of restricting containers with seccomp and AppArmor?
The main cost driver is how many workloads need profiles and how many of them are sensitive enough to need custom work. Applying the default seccomp profile to every workload is mostly configuration and testing. Writing custom seccomp profiles or AppArmor profiles for sensitive pods adds analysis, test cycles and sign-off. Node OS consistency also matters, because AppArmor depends on the host kernel and distribution, so mixed node pools add testing. Most of the cost is paid for in engineering time, not software, since both mechanisms are built into Kubernetes and Linux. Ask any partner to price the workload inventory, custom profile count, test environments and node pool variations separately in the written scope.
How long does a seccomp and AppArmor rollout take?
Duration depends on the number of namespaces and workloads, how many applications need custom profiles, and how quickly application owners can run and review test traffic. A rollout that starts in audit or warning mode moves at the pace of those test cycles, and each application that breaks under a profile adds a fix and a retest. No fixed duration applies to every cluster. Ask for a timeline tied to the workload inventory and the number of profiles in scope, and confirm which application teams must be available for testing and sign-off.
What does the platform and application team need to provide?
Platform engineers need admin access to the cluster, control over the kubelet and container runtime configuration on each node, and a way to roll out changes through their normal delivery path. Application teams need to describe what each service does, including system calls and file access it depends on, and to run representative test traffic in a non-production environment. They also need to own the decision about whether a failure is a profile problem or a bug in the application. Without named owners on both sides, profile exceptions tend to pile up.
Can our own team restrict containers with seccomp and AppArmor without a partner?
Yes, if the team has Kubernetes administration skills, Linux kernel and AppArmor familiarity, and time to test applications. The RuntimeDefault seccomp profile can be enabled in pod security settings with limited custom work, while AppArmor profiles and custom seccomp profiles need more analysis and repeated testing. A partner makes sense when the team lacks that time or when the work must meet a documented schedule. Compare the internal effort against a written scope that lists the workloads, profile types and test environments.
How do seccomp and AppArmor relate to Pod Security Standards and policy engines?
Pod Security Standards define three levels (Privileged, Baseline and Restricted) and are enforced per namespace by the built-in Pod Security Admission controller. The Restricted level requires a seccomp profile to be set, so seccomp is part of that baseline discussion. Seccomp and AppArmor settings live in the pod or container securityContext, while admission and policy engines such as Kyverno or OPA Gatekeeper can require, mutate or audit those fields across the cluster. Plan the namespace levels first, then decide which policy engine enforces profile exceptions and where audit results go.
Why do applications break after a seccomp or AppArmor profile is applied?
A profile blocks any system call or file operation it does not allow, and applications often use calls that were not visible in initial testing, such as rare error-handling paths, startup routines or library calls on specific kernels. Testing should cover startup, normal traffic, upgrades, background jobs and failure paths. Running in audit or log mode first helps reveal denied actions before enforcement. Confirm with each vendor which kernel features and system calls the product needs, because documentation is not always complete.
What does a DeployOpen engagement deliver for seccomp and AppArmor?
Under a written scope, DeployOpen can review the workload inventory, define which workloads receive RuntimeDefault seccomp, design and test custom profiles for sensitive pods, prepare AppArmor profiles where the node OS supports them, and document the test results and exceptions. Deliverables, environments and timelines are agreed in writing before work starts, and a quote follows from that scope. Ongoing profile maintenance can be covered by a retainer if the client wants continued support.
Where the Kubernetes documentation defines these controls
Start with the Pod Security Standards page when you need the exact meaning of the Baseline and Restricted profiles, because those profiles decide how seccomp and AppArmor settings are handled in a namespace. The page describes what each standard requires, and the fields that carry seccomp and AppArmor settings, such as securityContext.seccompProfile and the AppArmor configuration on containers, can change between releases. Read the page for the version your cluster runs, then compare it with the behavior you see in your own admission results before you write any policy that depends on it.
Check the Kubernetes releases page before you implement anything, because support windows and feature maturity differ by minor version. The project supports only the three most recent minor releases, so a cluster on an older minor version may be missing fields, defaults or fixes that this topic assumes. Confirm the exact version of your kube-apiserver, kubelets and container runtime, since AppArmor support also depends on the node operating system and kernel, which the Kubernetes documentation does not decide for you.
Use the CIS Kubernetes Benchmark as a consensus configuration guide for the rest of your review. It lists recommendations for pod security and node settings that you can compare against your own profiles, and it covers managed services as well as upstream Kubernetes. Treat it as a checklist to reconcile with your own risk decisions, not as a pass or fail result, and cite the benchmark version you used when you record exceptions for workloads that cannot meet a recommendation.
How DeployOpen scopes and delivers seccomp and AppArmor hardening
DeployOpen treats seccomp and AppArmor as a staged change to your workloads, not a single switch. We scope which namespaces and pods get RuntimeDefault, which sensitive workloads need custom profiles, and how profiles are rolled out and tested so applications keep running. The work is delivered inside the cluster infrastructure you control.
How we scope
- We inventory workloads by namespace and sensitivity to decide where RuntimeDefault seccomp applies first.
- We identify pods that need custom seccomp profiles or AppArmor profiles and record the reason for each.
- The written scope names the clusters, namespaces, workloads, environments and acceptance tests covered, agreed before work starts.
How we build
- We set seccomp and AppArmor fields through securityContext in manifests and Helm values, kept under version control.
- We run profiles in a staging namespace first, logging denied system calls and tuning profiles until applications pass tests.
- We document each custom profile, its owner and the workloads that depend on it, so later changes are reviewed against known needs.
How we hand over
- You receive the profiles, manifests, rollout runbook and a test record showing which workloads were verified.
- We document how to roll back a profile for a single workload without disabling the control cluster-wide.
- Ownership is transferred to your platform team with notes on updating profiles when application images or kernels change.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after the initial hardening work.
- Retesting after new workloads, Kubernetes minor version upgrades or node operating system changes can be included in a retainer.
- Quotes follow from the written scope, so ask for the list of workloads, environments and retest cycles each price covers.

