Skip to main content

Workload hardening and admission

Workloads
Harden the workload with one attribute, then make the cluster insist on it

An application's security context comes from one multi-select attribute. Admission policy then makes the cluster refuse workloads that fall short. The two are designed to meet: each option names the policy it satisfies.

Workload hardening​

security_features is a multi-select attribute on the application components (external source code, image base, FastAPI) and on the MCP server. Each option renders part of the pod's security context.

OptionRendersSatisfiesBreaks when
pod_securityrunAsNonRoot, runAsUser, runAsGroup, fsGroup from user_id and group_id; the namespace's Pod Security labels at restricted for warn and auditsecuritycontext (non-root)The image only works as root
container_securityShorthand for no_privilege_escalation and drop_capabilitiessecuritycontext, disallowAs its two parts
no_privilege_escalationallowPrivilegeEscalation: false, privileged: falsesecuritycontext, disallowThe application uses setuid binaries such as sudo
drop_capabilitiescapabilities.drop: [ALL]; entries of the capabilities attribute are still addedHardening checksPorts below 1024 without NET_BIND_SERVICE; binaries with file capabilities
read_only_fsreadOnlyRootFilesystem with a writable /tmpsecuritycontext (read-only root)The application writes outside /tmp without a declared writable directory
seccompseccompProfile: RuntimeDefaultsecuritycontext with seccomp enforcedRare system calls (mount, ptrace, bpf)
apparmorappArmorProfile: RuntimeDefaultsecuritycontext with AppArmor enforcedClusters before Kubernetes 1.30, nodes without AppArmor
no_host_accesshostNetwork, hostPID, hostIPC off (the default)pod_level_securityNever
no_automountNo Kubernetes API token in the pod—Application code that calls the Kubernetes API
privilege_escalationallowPrivilegeEscalation: true onlyFails securitycontext and disallowReview why it is needed
privilegedFull device and kernel accessFails securitycontext and disallowOnly for applications that truly need it

The value is the complete list. An application whose image runs as root (user_id 0) should get these on a non-production environment first.

Admission policy​

The OPA component runs Gatekeeper. Each policy family is a sub-component, which renders a constraint template and its constraint.

Sub-componentWhat it refuses
securitycontextA container without allowPrivilegeEscalation: false, a privileged container, a writable root filesystem, a container that may run as root; seccomp and AppArmor profiles when the sub-component's enforce_seccomp_profile and enforce_apparmor are on
disallowPrivileged containers, a missing allowPrivilegeEscalation: false, images tagged :latest
pod_level_securityHost network, host PID, host IPC and hostPath volumes
resource_policyA pod whose main container declares no CPU and memory requests and limits. Only a create or a change of the pod spec is judged: removing a finalizer or patching a label is never refused
probesA main container without a liveness and a readiness probe
image_policyImages outside the registry allow-list, tag rules, optional digest pinning — for regular, init and ephemeral containers
image_signingImages without a valid signature
label_denyWorkloads that do not carry a required label and value
network_policy_enforcementA namespace with workloads and no network policy, and network policies that are wide open
rbac_enforcementWorkloads on the default service account, wildcard roles; an opt-in identity guard
customYour own constraint

Each control maps to PCI DSS and ISO 27001 requirements, which the compliance scans use — see Compliance automation.

The OPA component also renders one mutation when the stack configuration sets ttl: every Job in the cluster that sets no ttlSecondsAfterFinished of its own — rendered by a chart, created by an operator or launched by an application — gets that value, so finished Jobs do not pile up. Namespaces listed in the configuration's namespaces_exclude are left alone.

Scope​

A policy's labels attribute becomes a selector. Every object and namespace the stack renders carries stacktic.io/stack: "<system name>", and application pods also carry env: with the component's environment. A selector that matches neither protects nothing, and the admission scan says so (NO_SCOPE).

On every policy, the namespaces attribute limits it to the namespaces listed, one per line, and excluded_namespaces exempts namespaces. A component that cannot satisfy a policy by design is exempted by the template itself — the VPN's namespace from securitycontext, because the WireGuard server must run as root with NET_ADMIN. The carve-outs a stack needs for its operators are planned from the knowledge layer — see Admission policy from your topology.

Mode​

opa_action on each policy sub-component is its enforcement: dryrun records violations, warn admits and warns, deny refuses. The OPA component's opa_failure_policy decides what happens when Gatekeeper itself does not answer: Ignore admits, Fail refuses.

DRYRUNrecord onlyviolations listedWARNadmit and warnkubectl shows itDENYrefusethe pod is rejectedopa_action on each policy sub-componentscan · fix · scopescan · fix · scope
The safe order for every policy: widen its scope at dryrun or warn, run the admission scan, fix the carve-outs, then deny.

Widening a deny policy from nothing to the whole stack blocks every non-compliant pod at once. The safe order is the same for every policy: scope it at warn, run the admission scan (scan(scanner='opa', mode='full') through the MCP), fix or carve out what it finds, then deny. The full scan dry-runs each constraint with a resource that should pass and one that should not, and classifies it as enforcing, not enforcing, over-enforcing or broken.

The identity guard​

rbac_enforcement carries an opt-in identity guard (identity_guard_action: off by default, then warn, dryrun or deny). The requesters it trusts are derived from the stack — Reloader, the stack agent's deploy arm — and requesters holding every permission are never judged. Turn it on at warn first, and only on a stack whose OPA component was rebuilt once with the template that renders its constraint template.

When a policy blocks an apply​

Tune the policy to the stack — its scope, an exclusion, its mode — and rebuild. Never remove it, and never patch the cluster around it: the next build would bring it back, and the evidence would show a control that was not in force.

→ Security, layer by layer · Admission policy from your topology