Kubernetes DevSecOps integrates security into every point where a workload changes, from commit and build to registry, admission, deployment, and runtime. Each control needs an enforcement outcome, an owner, and evidence that it ran, so security becomes part of the delivery path rather than a parallel scanning process.
A scanner alone will not provide that control. A repository can pass every CI check and still deploy an unsafe pod after a Helm value, operator, or mutating webhook changes the final specification. A team can create NetworkPolicy objects and remain broadly exposed because the cluster network plugin does not enforce them. Green pipeline. Open cluster.
This playbook maps the policy-as-code controls required across a production Kubernetes delivery path. It explains where each control belongs, when it should block a release, when it should warn, and when it should route a finding to an accountable owner.
In this playbook, you will get:
- A control map from pull request to runtime
- Practical blocking criteria for CI and admission
- Pod security, workload identity, secrets, and network examples
- Implementation notes for EKS, AKS, and GKE
- A 30/60/90-day rollout sequence
- Metrics that show whether the controls work after launch
Implementation blueprint for Kubernetes DevSecOps
A Kubernetes DevSecOps architecture must cover the complete delivery path: pull request, build, registry, CD and GitOps, admission, and runtime. A gap at any handoff can invalidate the controls applied earlier. The repository may be secure while the final workload is not.
Risk compounds across the application, infrastructure, network, and runtime layers. Each control therefore needs an enforcement point, a decision, retained evidence, and an accountable owner.
Use three possible outcomes:
- Block: the build or deployment cannot continue.
- Warn: delivery continues, but the risk remains visible.
- Route: the finding is assigned to an owner with a remediation deadline.
| Control point | Security control | Enforcement decision | Evidence | Owner |
|---|---|---|---|---|
| Repo and PR | Secret, IaC, and manifest checks | Block deterministic, high-impact violations; warn or route the rest | Result linked to commit SHA | Application team |
| Build and registry | Dependency and image scanning, SBOM, provenance, signing | Block release criteria without an approved exception | Scan report, SBOM, image digest, signature | Application and platform teams |
| CD and GitOps | Artifact promotion and environment configuration | Block unapproved artifacts or missing ownership data | Release manifest and approval record | Application and platform teams |
| Admission | Pod, identity, network, and image policies | Reject the final object when it violates the cluster baseline | Admission decision and policy version | Platform and security teams |
| Runtime | Behavioral detection and drift monitoring | Contain high-confidence threats; route other findings | Alert, owner, and response action | Security operations |
Exceptions apply across every control point. Each exception must include an owner, justification, compensating control, and expiration date. If one of those fields is missing, the exception should not be approved.
Do not build a control catalog that the organization cannot enforce or operate. A blueprint becomes real only when every control produces a decision, evidence, and an owned next action.
Threat model and security controls across the stack
Kubernetes expands the attack surface because a single release crosses source control, build infrastructure, a registry, deployment automation, the Kubernetes API, cloud identity, cluster networking, nodes, and runtime processes. The threat model must follow that path.
| Attack path | Example | Preventive control | Detection and evidence |
|---|---|---|---|
| Source to build | Leaked token or malicious dependency enters a pull request | Secret scanning, dependency policy, protected branches | Scan result tied to commit and reviewer approval |
| Build to registry | Compromised builder publishes an untrusted image | Isolated builders, SBOM, provenance, signing, immutable tags | Builder identity, image digest, signature, provenance statement |
| Registry to deployment | A mutable tag resolves to a different artifact | Digest pinning and promotion policy | Deployed digest compared with approved release digest |
| Deployment to admission | A Helm value or webhook adds privilege | Admission checks against the final object | Admission decision, policy version, rejected object |
| Workload to cloud API | A shared or overprivileged identity is abused | Dedicated service account and federated workload identity | Cloud audit event mapped to namespace and service account |
| Pod to pod | An exposed workload moves laterally | Default-deny ingress and egress with explicit allow rules | Effective policy coverage and network telemetry |
| Runtime to persistence | A process spawns a shell or writes an unexpected binary | Restricted pod baseline, read-only filesystem, runtime detection | Runtime event, workload owner, containment action |
The most damaging paths cross layers. An exposed application can become a cluster incident when it runs as a privileged pod, uses a shared service account, reaches the node metadata endpoint, and can communicate with every namespace. Security reviews should therefore evaluate complete attack paths rather than isolated YAML fields.
Use a recurring DevSecOps vulnerability management loop to reassess exploitable paths, exception age, and remediation ownership as the environment changes.
Pre-merge security controls
Pre-merge controls give developers the fastest feedback and prevent known-bad configuration from becoming a deployable artifact. They should scan:
- Credentials, private keys, and high-confidence secret patterns
- Kubernetes manifests, Helm templates, Kustomize output, and IaC
- Dependency and license policy
- Privileged containers, host namespaces, hostPath mounts, unsafe capabilities, and unrestricted ingress
- Required metadata such as owner, service, environment, and data classification
Render the configuration that will actually be deployed. Scanning a Helm template without its production values misses the object that matters.
Example CI gate
The following example uses explicit exit codes so a high-confidence failure stops the job:
- name: Scan rendered Kubernetes configuration
run: |
helm template payments ./charts/payments \
--values ./charts/payments/values-production.yaml > rendered.yaml
trivy config --severity HIGH,CRITICAL --exit-code 1 rendered.yaml
- name: Scan the release image
run: |
trivy image --severity CRITICAL --exit-code 1 "${IMAGE_DIGEST}"
The tool is replaceable; the decision rule is not. Block a pull request when the result is deterministic, exploitable, and attributable to the proposed change. Warn when context is incomplete. Route findings that require investigation to an owner with a due date.
Avoid blocking on every scanner result. A noisy control teaches developers to bypass the pipeline. Start with credentials, privileged execution, forbidden host access, unapproved registries, and release-blocking vulnerabilities. Add controls only after you can measure false positives and provide a documented fix.
For a broader view of the relationship between security checks and delivery automation, see DevSecOps vs CI/CD. These pre-merge controls also support the six pillars of DevSecOps by making shared responsibility, automation, and measurement concrete.
Build and software supply-chain integrity
Pre-merge checks validate source and configuration. The build stage must establish trust in the artifact itself.
For every production image:
- Build in an isolated, reproducible environment.
- Record the source revision and builder identity.
- Generate an SBOM in a standard format.
- Scan operating-system and application packages.
- Produce provenance that links the artifact to the approved build.
- Sign the image or use keyless signing backed by an approved identity.
- Push to an approved registry and promote by immutable digest.
- Verify the digest and signature before deployment.
SLSA provenance defines verifiable information about where, when, and how an artifact was produced. Sigstore verification guidance shows how a consumer can verify a signed container image. The objective is not to collect more files; it is to make an unauthorized artifact fail promotion or admission.
Use the image digest as the release identity. A tag such as payments:1.8 can move. A digest identifies exact content.
Block when an image comes from an unapproved registry, is referenced only by a mutable tag, lacks required provenance or signature, or violates the defined vulnerability threshold without an active exception. Retain the scan report, SBOM, digest, signature result, source revision, and builder identity as evidence.
These controls are among the most direct DevSecOps benefits: they prevent late ambiguity about what was built, approved, and deployed.
Admission control: validate the final Kubernetes object
CI and admission solve different problems.
- CI evaluates repository content before an artifact is released.
- Admission evaluates the final Kubernetes API request after rendering, overlays, operators, and mutating webhooks have influenced it.
You need both. CI provides early feedback; admission protects the cluster when the final object differs from the repository or bypasses the expected pipeline.
Admission should enforce controls that must always be true:
- Images come from approved registries and are pinned by digest.
- Production images pass signature verification.
- Privileged containers and forbidden host access are rejected.
- Required CPU and memory settings exist.
- Production workloads use an approved service account.
- Required ownership labels are present.
- High-risk namespaces meet the Restricted Pod Security Standard.
Admission-policy pseudocode
IF namespace.environment == "production"
AND container.image is not pinned to "@sha256:..."
THEN deny the request
WITH message "Production images must use an approved immutable digest"
AND record policy version, namespace, workload, repository, and owner
Gatekeeper or Kyverno?
| Choose | Best fit | Operational consideration |
|---|---|---|
| Gatekeeper | Teams already using OPA/Rego or requiring a centralized policy language | Rego expertise and template lifecycle need clear ownership |
| Kyverno | Kubernetes-native YAML workflows and policies close to platform configuration | Keep policy tests and generated/mutated resources under review |
The engine matters less than the operating model. Version policies, test them against representative manifests, deploy new rules in audit mode, measure impact, and then enforce. Record the rule, policy version, request, decision, and exception reference for every denial.
Pod security baseline with PSA and PSS
PodSecurityPolicy is removed from current Kubernetes releases. Use Pod Security Admission to apply the Pod Security Standards at the namespace level.
The three profiles have different purposes:
- Privileged: unrestricted; reserve for narrowly controlled system workloads.
- Baseline: prevents known privilege-escalation patterns while allowing common workloads.
- Restricted: applies the hardened baseline expected for most production applications.
Example namespace configuration
apiVersion: v1
kind: Namespace
metadata:
name: payments-production
labels:
pod-security.kubernetes.io/enforce: restricted
pod-security.kubernetes.io/enforce-version: latest
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/warn: restricted
Pair this with workload settings such as non-root execution, allowPrivilegeEscalation: false, dropped Linux capabilities, RuntimeDefault seccomp, and a read-only root filesystem where the application permits it. The official Kubernetes security checklist provides a useful baseline for these cluster and workload controls.
For migration, label a namespace with warn and audit first, inventory violations, remediate standard workloads, isolate legitimate privileged components, and only then enable enforce. Do not grant a namespace-wide exemption for one incompatible daemon. Move it into a dedicated, tightly controlled namespace.
This staged approach preserves delivery speed while improving the baseline, which is also central to the practical distinction between DevSecOps and Agile.
Kubernetes secrets and workload identity
Kubernetes Secret objects are not a complete secrets-management system. By default, Secrets are stored unencrypted in etcd unless encryption at rest is configured. Kubernetes also recommends least-privilege access, restricting list and watch, using short-lived credentials, and considering external secret stores. See the official Kubernetes Secrets good practices.
Use this order of preference:
- Avoid a secret when the workload can use federated identity.
- Use short-lived credentials issued for a dedicated workload identity.
- Retrieve remaining secrets from an approved external store.
- If a Kubernetes Secret is required, encrypt it at rest, restrict RBAC, limit distribution, and rotate it.
Never commit plaintext credentials, place them in image layers, or expose them through environment dumps and debug logs. A base64-encoded Kubernetes Secret is encoding, not encryption.
Workload identity control map
| Platform | Preferred workload identity | Binding to verify | Common failure to block |
|---|---|---|---|
| EKS | EKS Pod Identity or IRSA | Namespace and Kubernetes service account to scoped IAM role | Pod falls back to an overprivileged node role |
| AKS | Microsoft Entra Workload ID | OIDC issuer, federated credential, service account, managed identity | Shared identity or incorrect subject/audience |
| GKE | Workload Identity Federation for GKE | Namespace/service account principal to scoped IAM permission | Workload inherits broad node credentials or project access |
Every production workload should use a dedicated Kubernetes service account with automountServiceAccountToken: false unless it calls the Kubernetes API. Grant Kubernetes RBAC and cloud IAM separately. Review wildcard verbs, cluster-wide bindings, impersonation rights, and the ability to create workloads as privilege-escalation paths. The current Kubernetes RBAC good practices provide further review guidance.
Identity is a platform contract, not an application afterthought. Define which team creates the cloud identity, who binds it to the service account, who approves permissions, and which audit event proves that the intended identity was used. This accountability also clarifies the DevSecOps roles and responsibilities across application, platform, and security teams.
Network isolation with NetworkPolicy
A Kubernetes NetworkPolicy object has value only when the cluster network plugin enforces it. The Kubernetes API documentation explicitly notes that the cluster must use a supporting network plugin. Verify enforcement with a connectivity test, not by counting objects. See the official NetworkPolicy documentation.
Start each application namespace with default-deny ingress and egress:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
namespace: payments-production
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
Then add explicit allow policies for required paths such as ingress controller to application, application to database, application to DNS, and approved external endpoints. Review both directions. An ingress-only baseline still allows a compromised pod to scan the cluster or exfiltrate data.
Test from representative pods after every policy change. Confirm allowed paths succeed and denied paths fail. Include DNS, monitoring, service mesh, and control-plane dependencies in the test plan. Document the purpose and owner of each allow rule so temporary connectivity fixes do not become permanent exposure.
Runtime detection, response, and drift control
Pre-deployment controls cannot predict every exploit, zero-day, credential abuse, or operator action. Runtime security must connect a high-signal event to an owner and a response.
Prioritize signals such as:
- Shell execution or unexpected child processes in a production container
- Writes to sensitive paths or execution from writable directories
- Privilege escalation, new capabilities, host namespace access, or suspicious mounts
- Unexpected outbound connections, cryptocurrency mining behavior, or port scanning
- Kubernetes API calls inconsistent with the service account's role
- Deployment drift from the approved digest, manifest, identity, or policy state
For each rule, define the signal source, severity, workload owner, response action, and evidence retained. Contain automatically only when confidence is high and the blast radius of automation is understood. Route ambiguous events to the responsible team with workload, namespace, image digest, identity, recent change, and recommended action attached.
A practical response sequence is: isolate the affected workload, preserve evidence, revoke or rotate credentials, restore from an approved artifact, verify policy and network state, and document the root cause. Kubernetes-specific incident procedures should connect to the broader DevSecOps container security program rather than operate as a separate alert queue.
Audit evidence, ownership, and exceptions
Evidence should answer five questions without reconstructing the event manually:
- What changed?
- Which control evaluated it?
- What decision did the control make?
- Who owned the workload and the response?
- Which artifact, policy, and exception versions were active?
Retain commit SHA, build identity, SBOM, provenance, image digest, signature result, deployment approval, admission decision, workload identity, policy version, runtime alert, and response action. Link them by service, environment, namespace, and owner.
Example exception record
exception_id: K8S-2026-014
control: require-read-only-root-filesystem
scope: payments-production/reconciliation-worker
owner: payments-platform
justification: legacy library writes temporary indexes to the image filesystem
compensating_control: dedicated namespace, restricted identity, egress allowlist
approved_by: security-platform
created: 2026-07-17
expires: 2026-08-31
remediation_ticket: PAY-4821
An exception without an owner or expiry is a policy change disguised as temporary risk acceptance. Alert before expiration, prevent silent renewal, and report expired exceptions as control failures.
Cloudaware can provide the asset and ownership context around this evidence. Its Kubernetes integration can help teams relate Kubernetes resources to the surrounding multi-cloud environment, so policy results and operational signals can be routed with service, environment, and owner context.
EKS, AKS, and GKE implementation notes
The control points stay consistent across managed Kubernetes services, but identity, networking, logging, and policy integrations differ.
| Control area | Amazon EKS | Microsoft AKS | Google GKE |
|---|---|---|---|
| Workload identity | Use EKS Pod Identity or IRSA; scope the IAM role to namespace and service account | Enable the OIDC issuer and Microsoft Entra Workload ID; verify the federated subject and audience | Use Workload Identity Federation for GKE with fine-grained principals or service-account impersonation |
| Node credential risk | Restrict IMDS access and prevent fallback to broad node roles | Separate kubelet/cluster identities from pod identities | Prevent workloads from relying on broad node service-account access |
| Network enforcement | Confirm the installed CNI and policy engine enforce ingress and egress | Verify the selected network data plane and policy mode | Verify Dataplane/CNI behavior and test effective policy |
| Admission and pod baseline | Apply PSA plus Gatekeeper/Kyverno or an approved managed equivalent | Apply PSA plus Azure-integrated or in-cluster policy controls | Apply PSA plus GKE-integrated or in-cluster policy controls |
| Audit evidence | Retain EKS control-plane, IAM, registry, and workload events | Retain AKS control-plane, Entra, registry, and workload events | Retain GKE audit, IAM, registry, and workload events |
For EKS, confirm that every Pod Identity association maps the intended role to one service account and namespace. For AKS, test the OIDC issuer, federated credential, service-account annotation or label requirements, and SDK behavior. For GKE, test the exact IAM principal used by the namespace and service account. In every platform, deploy a canary workload that must succeed with the intended permission and fail outside it.
Platform-native services are implementation adapters. Keep the security objectives portable: dedicated identity, immutable artifact, enforced admission, verified network isolation, complete evidence, and accountable response.
30/60/90-day Kubernetes DevSecOps rollout
Do not enable every blocking control on day one. Establish visibility, fix high-confidence risks, and then increase enforcement.
Use canary namespaces and representative services before broad enforcement. Publish remediation guidance with every new rule. Track policy denials by repository so a noisy control is fixed rather than normalized.
The rollout succeeds when teams can deploy safely through the standard path without opening exception tickets for ordinary workloads. Speed comes from reusable secure defaults, not from weakening the gate.
Kubernetes DevSecOps metrics
Metrics should show coverage, control effectiveness, and response. Avoid invented benchmarks; calculate a baseline and improve it deliberately.
| Metric | Formula | What it reveals |
|---|---|---|
| Production namespaces enforcing PSS Restricted | Restricted production namespaces / all production namespaces × 100 | Pod-baseline coverage |
| Dedicated service-account coverage | Production workloads with dedicated service accounts / all production workloads × 100 | Shared-identity risk |
| Digest-pinned deployment coverage | Production containers deployed by digest / all production containers × 100 | Image immutability |
| Signed-image verification coverage | Verified production deployments / all production deployments × 100 | Supply-chain enforcement |
| Network default-deny coverage | Namespaces with enforced ingress and egress default deny / in-scope namespaces × 100 | Network isolation |
| Exception expiration compliance | Exceptions closed or renewed before expiry / exceptions reaching expiry × 100 | Governance operation |
| Runtime routing coverage | Actionable runtime findings assigned to an owner / all actionable runtime findings × 100 | Whether telemetry becomes response |
| Median critical remediation time | Median of remediation timestamp − detection timestamp | Remediation speed |
Also trend admission denials by rule, repository, and namespace; open exceptions by age; signature failures; and connectivity-test failures. A sudden increase can mean a new attack path, a broken deployment pattern, or a poorly introduced policy. The metric should trigger investigation rather than exist only on a dashboard.
Industry DevSecOps statistics can provide market context, but the operational baseline for this program must come from your own clusters, pipelines, owners, and response data.