Skip to content

Lab 07 — Workload Security

You have now secured several layers of Kubernetes:

Lab 01 — Kubernetes Fundamentals
Understand Resources
Lab 02 — Kubernetes RBAC
Control Identity
Lab 03 — Kyverno
Enforce Security Policy
Lab 04 — Network Policies
Control Communication
Lab 05 — OPA Gatekeeper
Enforce Governance
Lab 06 — Runtime Security
Detect Suspicious Behavior

In this final Kubernetes lab, you will secure the workload itself.

The central question is:

If this application becomes compromised,
how much power will the attacker inherit?

Your objective is to reduce that power.

You will transform an intentionally weak Kubernetes workload into a hardened workload using:

Non-Root Execution
Privilege Restrictions
Linux Capability Reduction
Read-Only Filesystems
Seccomp
Service Account Controls
Secrets Protection
Resource Controls
Image Governance
Pod Security Standards

Difficulty: Intermediate to Advanced

Estimated Time: 90–120 minutes

Primary Skills:

Kubernetes Workload Hardening
Pod Security
Container Security
Security Contexts
Linux Capabilities
Service Account Security
Secrets Security
Resource Governance
Container Image Security
Defense in Depth

Your security team is reviewing a Kubernetes application before production deployment.

The development team has confirmed:

Application Works Correctly

but the security review identifies several concerns:

Container May Run as Root
Privilege Escalation Is Not Restricted
Linux Capabilities Are Not Minimized
Root Filesystem Is Writable
Default Service Account Is Used
Service Account Token May Be Mounted
Resource Controls Are Missing
Image Uses a Mutable Tag
Network Restrictions Are Missing

Your mission is to:

Assess
Identify Risks
Harden
Deploy
Validate
Document

By the end of this lab, you should be able to:

  • Assess Kubernetes workload security
  • Understand Pod and container security contexts
  • Configure non-root execution
  • Prevent privilege escalation
  • Drop unnecessary Linux capabilities
  • Use read-only root filesystems
  • Understand seccomp protection
  • Review privileged containers
  • Review host namespace exposure
  • Review hostPath risks
  • Secure ServiceAccount usage
  • Reduce unnecessary token mounting
  • Protect Kubernetes Secrets
  • Configure CPU and memory controls
  • Evaluate container-image security
  • Understand Pod Security Standards
  • Build a workload-security baseline
  • Validate hardened workloads
  • Document professional security findings

Part 01 — Workload Security Mental Model

Section titled “Part 01 — Workload Security Mental Model”

A Kubernetes workload is not just:

Container Image

Its effective security depends on:

Image
+
Pod Specification
+
Security Context
+
Service Account
+
RBAC
+
Secrets
+
Volumes
+
Network Access
+
Runtime Configuration

Therefore:

Secure Image
Secure Workload

Part 02 — Why Workload Hardening Matters

Section titled “Part 02 — Why Workload Hardening Matters”

Consider:

Internet
Application
Application Vulnerability
Container Compromise

You cannot assume every application vulnerability will be prevented.

Instead ask:

What Happens Next?

If the workload has:

Root
Privileged Mode
Powerful Capabilities
Writable Host Mount
Powerful Service Account
Broad Network Access

the impact may become much greater.

Application Compromise
Restricted Container
Non-Root
Minimal Capabilities
Restricted Filesystem
Limited Identity
Restricted Network
Reduced Blast Radius

This is one of the main objectives of workload security.

Kubernetes provides:

securityContext

for defining important security properties.

Security settings can exist at:

Pod Level

and:

Container Level
spec:
securityContext:
# Pod-level controls
containers:
- name: application
securityContext:
# Container-level controls

Understanding which control belongs at which level is important.

Part 04 — Verify Your Training Environment

Section titled “Part 04 — Verify Your Training Environment”

Run:

Terminal window
kubectl config current-context

Then:

Terminal window
kubectl cluster-info

Verify:

Correct Cluster
Training Environment
Authorized Access

Do not perform hardening experiments directly against production workloads.

Create:

Terminal window
kubectl create namespace ghc-workload-security

Set it as your working namespace:

Terminal window
kubectl config set-context --current --namespace=ghc-workload-security

Verify:

Terminal window
kubectl config view --minify

Create:

baseline-workload.yaml

Add:

apiVersion: apps/v1
kind: Deployment
metadata:
name: baseline-web
namespace: ghc-workload-security
labels:
app: baseline-web
spec:
replicas: 1
selector:
matchLabels:
app: baseline-web
template:
metadata:
labels:
app: baseline-web
spec:
containers:
- name: web
image: nginx:alpine
ports:
- containerPort: 80

Apply:

Terminal window
kubectl apply -f baseline-workload.yaml

Verify:

Terminal window
kubectl get pods

Part 07 — Perform the Initial Security Assessment

Section titled “Part 07 — Perform the Initial Security Assessment”

Inspect:

Terminal window
kubectl get deployment baseline-web -o yaml

Then:

Terminal window
kubectl describe pod <baseline-pod-name>

Review:

Image
Service Account
Security Context
Resources
Volumes
Environment Variables
Container Ports

Ask:

Is runAsNonRoot configured?
Is privilege escalation prevented?
Are Linux capabilities dropped?
Is the root filesystem read-only?
Is seccomp configured?
Are resources defined?
Which ServiceAccount is used?
Is a token automatically mounted?
Is the image version controlled?

Part 08 — Build a Security Assessment Table

Section titled “Part 08 — Build a Security Assessment Table”

Create:

Control Current State Desired State
Non-root Review Required where supported
Privileged Review False
Privilege escalation Review False
Capabilities Review Minimized
Root filesystem Writable Read-only where possible
Seccomp Review RuntimeDefault
Resources Missing Defined
Service account Default Dedicated/minimal
Token mount Review Disabled if unnecessary
Image Mutable tag Controlled version/digest

This becomes your remediation plan.

One of the most important workload controls is:

Run as Non-Root

Why?

Because application compromise should not automatically provide:

Root-Level Container Access
Application Needs
Only Application Privileges

not:

Application Runs as Root
Because It Is Easier

Kubernetes supports:

securityContext:
runAsNonRoot: true

This tells Kubernetes that the workload should not run as UID 0.

Setting:

runAsNonRoot: true

does not magically make every image compatible with non-root execution.

The container image must support it.

Some images expect:

Root
Privileged Ports
Writable System Paths

When hardening breaks an application, do not automatically remove the control.

Ask:

Can We Use a Non-Root Image?
Can We Change the Port?
Can We Change File Permissions?
Can We Redesign Writable Paths?

Security hardening sometimes reveals poor application assumptions.

Part 12 — Create a Non-Root Training Workload

Section titled “Part 12 — Create a Non-Root Training Workload”

For this lab, use an image designed to operate without unnecessary root privileges.

Your workload security section should include:

spec:
securityContext:
runAsNonRoot: true

Depending on the image, you may also define an appropriate non-zero UID.

After deployment:

Terminal window
kubectl get pods

Then inspect the workload.

Where supported:

Terminal window
kubectl exec <pod-name> -- id

Expected:

Non-Zero UID

Another important control is:

allowPrivilegeEscalation: false

Conceptually:

Application Process
Cannot Gain Additional Privileges
Through Normal Privilege-Escalation Paths
securityContext:
allowPrivilegeEscalation: false

This helps reduce opportunities for:

Privilege Escalation

after application compromise.

Review:

privileged: true

Privileged containers receive extremely broad access compared with normal containers.

Conceptually:

Normal Container
Isolation Controls

versus:

Privileged Container
Significantly Reduced Isolation

Application workloads should generally use:

privileged: false

unless there is a documented and reviewed technical requirement.

Linux divides some root privileges into:

Capabilities

Examples include capabilities related to:

Networking
Process Management
System Administration
File Ownership
Kernel Operations

Containers may receive capabilities they do not need.

Instead of:

Give Broad Privilege

use:

Drop Everything
Add Only What Is Required

A strong starting point is:

securityContext:
capabilities:
drop:
- ALL

This removes available Linux capabilities from the container.

Applications requiring specific capabilities may need carefully reviewed exceptions.

The objective is:

Minimum Required Capabilities

For every application ask:

Which Capabilities Are Required?
Why?
Can the Application Work Without Them?
What Happens If the Container Is Compromised?

Do not add capabilities simply to make an application start without understanding why.

Containers often do not need to modify their root filesystem after startup.

Use:

securityContext:
readOnlyRootFilesystem: true

where compatible.

This can make it more difficult for compromised processes to:

Modify Application Files
Replace Binaries
Drop Persistent Tools
Alter Configuration

Some applications legitimately need writable directories.

The better architecture is often:

Read-Only Root Filesystem
+
Explicit Writable Volume

rather than:

Entire Container Filesystem Writable
Container Root
Read Only
/tmp
Writable Temporary Volume

Where appropriate, Kubernetes can provide temporary storage using:

emptyDir

Conceptually:

volumes:
- name: tmp
emptyDir: {}

and:

volumeMounts:
- name: tmp
mountPath: /tmp

This provides an explicitly writable location without requiring the entire root filesystem to remain writable.

Seccomp can restrict the Linux system calls available to processes.

A common Kubernetes hardening configuration is:

securityContext:
seccompProfile:
type: RuntimeDefault
Application
System Calls
Seccomp Policy
Allowed / Restricted

A compromised application should not automatically have unrestricted access to every available kernel interface.

Seccomp contributes another isolation layer.

A hardened container may conceptually use:

securityContext:
allowPrivilegeEscalation: false
privileged: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL

At Pod level:

securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
Non-Root
+
No Privilege Escalation
+
Not Privileged
+
Capabilities Dropped
+
Read-Only Root Filesystem
+
Seccomp

Every Pod operates with a Kubernetes ServiceAccount identity.

If none is explicitly configured, the Pod typically uses the namespace’s:

default

ServiceAccount.

Ask:

Does This Application
Need Kubernetes API Access?

Many applications do not.

Part 24 — Create a Dedicated Service Account

Section titled “Part 24 — Create a Dedicated Service Account”

Create:

Terminal window
kubectl create serviceaccount workload-app

Verify:

Terminal window
kubectl get serviceaccount workload-app

Then configure:

spec:
serviceAccountName: workload-app

It provides:

Clear Workload Identity
Better RBAC Control
Better Auditability
Reduced Shared Identity

Part 25 — Disable Unnecessary Token Mounting

Section titled “Part 25 — Disable Unnecessary Token Mounting”

If the workload does not require Kubernetes API access, consider:

automountServiceAccountToken: false

This reduces unnecessary credential exposure inside the container.

Conceptually:

Application Does Not Need API
Do Not Provide API Credential

Inspect:

Terminal window
kubectl describe pod <pod-name>

and the Pod YAML.

Determine whether Kubernetes API credentials are mounted.

No Requirement
No Credential

If the application does require Kubernetes API access, grant only required permissions.

Use:

Terminal window
kubectl auth can-i --list --as=system:serviceaccount:ghc-workload-security:workload-app

Review:

Secrets
Pods
Deployments
Jobs
ConfigMaps
Cluster Resources
cluster-admin

for ordinary applications.

Applications frequently need credentials such as:

Database Password
API Token
TLS Material
Application Secret

Avoid:

Hardcoded Secret in Image

and:

Hardcoded Secret in Git
Secret Source
Controlled Delivery
Application

Kubernetes Secrets provide a native mechanism for referencing sensitive values.

But remember:

Base64
Encryption

Secret security still depends on:

RBAC
Encryption at Rest
Access Controls
Rotation
External Secret Management
Logging Discipline

Look for:

Secrets in Environment Variables
Secrets in Command Arguments
Secrets in Logs
Secrets in ConfigMaps
Secrets Embedded in Images
Secrets Stored in Git

Reduce:

Secret Copies

and:

Secret Exposure Locations

A mature design supports:

Credential Created
Securely Delivered
Used
Rotated
Old Credential Revoked

Incident response becomes much easier when credentials can be rotated predictably.

Workload security also includes availability.

Define:

CPU Requests
Memory Requests
CPU Limits
Memory Limits

Example:

resources:
requests:
cpu: "100m"
memory: "64Mi"
limits:
cpu: "250m"
memory: "128Mi"

Without controls, a workload could contribute to:

Resource Exhaustion
Node Pressure
Application Instability
Denial of Service

Think:

Request
=
What the scheduler should reserve

and:

Limit
=
Maximum controlled resource usage

Exact behavior differs between CPU and memory, so administrators should understand the runtime implications.

Workload security starts before runtime.

Review:

Image Source
Image Tag
Image Digest
Base Image
Known Vulnerabilities
Image Size
Included Tools
Image User
Trusted Source
Minimal Image
Vulnerability Scanning
Controlled Version
Deployment

Part 35 — Avoid Uncontrolled Mutable Tags

Section titled “Part 35 — Avoid Uncontrolled Mutable Tags”

Avoid relying on:

latest

for controlled production deployment.

Why?

Deployment Manifest
Same Tag
Image Content Changes

This reduces predictability.

Use:

Controlled Version Tags

or stronger immutable references where required by your environment.

An image digest provides an immutable content reference.

Conceptually:

Repository
Image Digest
Exact Image Content

This strengthens:

Repeatability
Traceability
Supply-Chain Control

Large images may contain unnecessary:

Shells
Package Managers
Utilities
Libraries

Reducing unnecessary software can reduce:

Attack Surface
If the Application
Does Not Need It,
Do Not Include It.

Before deployment:

Image
Vulnerability Scan
Risk Evaluation
Approve / Remediate

Scanning should consider:

Severity
Exploitability
Runtime Reachability
Application Context
Available Fix

Do not treat every vulnerability as equal.

Review:

hostNetwork
hostPID
hostIPC

These features allow workloads to share aspects of the node environment.

Container Compromise
+
Host Namespace Access
Potential Increased Impact

Ordinary applications should not use these without a valid reason.

Review:

hostPath

volumes carefully.

A writable hostPath can expose host filesystem locations to a container.

Which Path?
Read-Only?
Why Required?
Could Another Volume Type Work?
What Happens After Container Compromise?

For every volume ask:

What Data?
Who Can Access It?
Read or Write?
Persistent?
Shared?
Sensitive?
Host-Backed?

Review environment variables for:

Secrets
Internal Endpoints
Cloud Credentials
Debug Flags
Sensitive Configuration

Avoid unnecessary sensitive values in locations easily exposed through:

Process Inspection
Debug Output
Support Bundles
Logs

Configure appropriate:

Startup Probes
Readiness Probes
Liveness Probes

These are primarily reliability controls, but workload resilience contributes to overall security and availability.

Poorly configured probes can create:

Restart Loops
Unavailable Applications

Security hardening must not ignore operational reliability.

Kubernetes Pod Security Standards define three conceptual policy levels:

Privileged
Baseline
Restricted

Provides broad permissions and minimal restrictions.

Appropriate only for workloads that genuinely require elevated capabilities and are carefully controlled.

Attempts to prevent common privilege-escalation risks while remaining broadly compatible.

Represents a stronger workload-hardening profile.

Conceptually:

Privileged
Baseline
Restricted

with security increasing as restrictions increase.

A restricted-style workload generally aims for controls such as:

Non-Root
No Privilege Escalation
Restricted Capabilities
Seccomp
No Privileged Container
Limited Host Access

The exact applicable requirements should be validated against your Kubernetes environment and current organizational standard.

Organizations can apply Pod Security Admission controls through namespace configuration.

Before changing namespace security settings, understand:

Existing Workloads
Required Policy Level
Enforcement Impact
Warnings
Audit Requirements
Understand
Audit
Warn
Remediate
Enforce

Your previous Kyverno and Gatekeeper labs now become relevant.

Instead of telling every developer:

Please Remember
runAsNonRoot

you can enforce:

Workloads Must
Run as Non-Root
Documentation
Recommendation
Automated Validation
Enforcement

A hardened workload should also have appropriate communication restrictions.

Ask:

Who Can Reach It?
Where Can It Connect?
Does It Need Internet Access?
Can It Reach Sensitive Services?

Use your NetworkPolicy knowledge.

Even a hardened workload can still be compromised.

Therefore:

Workload Hardening
+
Runtime Detection

provides stronger protection.

Non-Root
Reduces Impact
Runtime Detection
Detects Unexpected Shell

Now combine the controls.

Create:

hardened-workload.yaml

A representative structure is:

apiVersion: v1
kind: ServiceAccount
metadata:
name: workload-app
namespace: ghc-workload-security
automountServiceAccountToken: false
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hardened-web
namespace: ghc-workload-security
labels:
app: hardened-web
owner: platform-security
spec:
replicas: 1
selector:
matchLabels:
app: hardened-web
template:
metadata:
labels:
app: hardened-web
spec:
serviceAccountName: workload-app
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
containers:
- name: web
image: <approved-non-root-image>:<controlled-version>
ports:
- containerPort: 8080
securityContext:
privileged: false
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
resources:
requests:
cpu: "100m"
memory: "64Mi"
limits:
cpu: "250m"
memory: "128Mi"
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}

The image placeholder is intentional.

Choose a known training image that:

Supports Non-Root Execution
Uses the Configured Port
Works with Read-Only Root Filesystem

Do not blindly copy a root-dependent image into this hardened configuration and disable controls when it fails.

After selecting a compatible training image:

Terminal window
kubectl apply -f hardened-workload.yaml

Watch:

Terminal window
kubectl get pods -w

If it starts successfully, continue with validation.

If it fails:

Do Not Immediately Remove Security Controls

Investigate the cause.

Part 52 — Troubleshoot Hardened Workload Startup

Section titled “Part 52 — Troubleshoot Hardened Workload Startup”

Use:

Terminal window
kubectl describe pod <hardened-pod-name>

Then:

Terminal window
kubectl logs <hardened-pod-name>

Check:

Image Compatibility
Filesystem Writes
UID Requirements
Port Binding
Volume Permissions
Security Context
Pod Fails
Events
Logs
Security Configuration
Application Requirement
Secure Remediation

Where supported:

Terminal window
kubectl exec <hardened-pod-name> -- id

Confirm:

UID != 0

Record the evidence.

Inspect:

Terminal window
kubectl get pod <hardened-pod-name> -o yaml

Confirm:

runAsNonRoot: true
allowPrivilegeEscalation: false
privileged: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault

Check:

Terminal window
kubectl get pod <hardened-pod-name> -o jsonpath='{.spec.serviceAccountName}'

Expected:

workload-app

Then:

Terminal window
kubectl get serviceaccount workload-app -o yaml

Where authorized:

Terminal window
kubectl auth can-i --list --as=system:serviceaccount:ghc-workload-security:workload-app

Verify the workload has no unnecessary application permissions.

Application Identity
Minimum Required Access

Inspect:

Terminal window
kubectl describe pod <hardened-pod-name>

Confirm the application is not unnecessarily receiving a Kubernetes API credential.

Run:

Terminal window
kubectl describe pod <hardened-pod-name>

Confirm:

Requests
Limits

are present.

Part 59 — Validate Writable Filesystem Behavior

Section titled “Part 59 — Validate Writable Filesystem Behavior”

With an approved lab image, test only harmless paths.

Attempting to write to a protected root-filesystem location should fail when the filesystem is read-only.

The explicitly writable path such as:

/tmp

should behave according to the mounted temporary volume.

You have changed:

Everything Writable

into:

Only Required Locations Writable

Create:

Security Control Baseline Hardened
Non-root Not guaranteed Required
Privileged Not explicitly controlled False
Privilege escalation Not restricted False
Capabilities Default Dropped
Root filesystem Writable Read-only
Seccomp Review RuntimeDefault
Service account Default Dedicated
Token Potentially mounted Disabled if unnecessary
Resources Missing Defined
Image Basic tag Controlled image/version

Before:

Application Compromise
Broad Container Privileges
Credential Access
Network Access
Potential Expansion

After:

Application Compromise
Non-Root
No Privilege Escalation
Minimal Capabilities
Read-Only Filesystem
Minimal Identity
Restricted Network
Reduced Blast Radius

Document the original workload.

Finding:
Application Container Lacks
Workload Hardening Controls
Affected Resource:
baseline-web
Namespace:
ghc-workload-security
Observation:
The workload does not explicitly implement
several recommended container security controls.
Threat Scenario:
If the application is compromised,
the attacker may inherit broader runtime
capabilities than required.
Risk:
High
Recommendation:
Implement a workload security baseline
including non-root execution,
privilege restrictions,
capability reduction,
seccomp and filesystem hardening.
Finding:
Application Uses Default Service Account
Observation:
The application does not use a dedicated
workload identity.
Risk:
Medium
Recommendation:
Create a dedicated ServiceAccount,
grant only required permissions,
and disable automatic token mounting
when Kubernetes API access is unnecessary.
Finding:
Container Resource Controls Are Missing
Observation:
CPU and memory requests and limits
are not explicitly configured.
Threat Scenario:
Unexpected resource consumption could
affect workload or node availability.
Recommendation:
Define resource requests and limits
based on application performance requirements.

Use:

Finding:
Affected Resource:
Namespace:
Observed Configuration:
Expected Configuration:
Evidence:
Threat Scenario:
Business Impact:
Risk:
Recommendation:
Remediation:
Validation:

Part 66 — Workload Security Review Framework

Section titled “Part 66 — Workload Security Review Framework”

For every workload review:

01 Image
02 User
03 Privilege
04 Capabilities
05 Filesystem
06 Seccomp
07 Service Account
08 RBAC
09 Secrets
10 Volumes
11 Network
12 Resources
13 Logging
14 Runtime Detection

Ask:

Where Did the Image Come From?
Is the Registry Trusted?
Is the Image Scanned?
Does It Run as Root?
Is the Version Controlled?
Is the Image Minimal?
Are Unnecessary Tools Included?

Ask:

Which ServiceAccount?
Does It Need API Access?
What RBAC Permissions?
Is Token Mounting Required?
Is Cloud Workload Identity Used?
Could Permissions Be Reduced?

Ask:

Is privileged Enabled?
Can Privilege Escalation Occur?
Which Capabilities Exist?
Is Root Required?
Are Host Namespaces Used?
Are Host Volumes Used?

Ask:

Is Root Filesystem Writable?
Which Paths Need Write Access?
Can Explicit Volumes Be Used?
Are Sensitive Volumes Mounted?
Are Host Paths Exposed?

Ask:

Who Can Reach the Workload?
Where Can It Connect?
Is Default-Deny Used?
Does It Need Internet Egress?
Can It Reach Sensitive Internal Services?

Ask:

Which Secrets Are Available?
Does the Application Need Them?
How Are They Delivered?
Who Can Read Them?
Are They Rotated?
Could Logs Expose Them?

Ask:

Is Runtime Monitoring Enabled?
Can Unexpected Shells Be Detected?
Can Suspicious Processes Be Detected?
Can Sensitive File Access Be Detected?
Can Network Anomalies Be Investigated?

Once your hardened baseline is validated, automate it.

Use technologies from earlier labs:

Pod Security Admission
Kyverno
OPA Gatekeeper

Possible policies:

Require Non-Root
Block Privileged
Block Privilege Escalation
Require Seccomp
Restrict Capabilities
Require Resource Controls
Restrict Registries

Manual review:

100 Workloads
100 Security Reviews

Automated guardrails:

Security Standard
Policy-as-Code
Every Deployment Evaluated

Create an organizational baseline:

All Standard Application Workloads:
Must run non-root
Must not run privileged
Must prevent privilege escalation
Must minimize capabilities
Must use approved seccomp configuration
Should use read-only root filesystem where compatible
Must use controlled images
Must define resources
Must use least-privileged identity
Must follow network segmentation requirements

Some workloads may require elevated functionality.

Examples can include certain:

Networking Components
Storage Components
Security Agents
Node-Level Utilities

Do not weaken the baseline globally.

Use:

Specific Exception
Documented Requirement
Risk Assessment
Compensating Controls
Approval
Review Date
Workload:
Namespace:
Security Control:
Requested Exception:
Technical Reason:
Risk:
Compensating Controls:
Owner:
Approver:
Expiration:
Review Date:

You discover:

privileged: true

Ask:

Why Is It Required?
Can It Be Removed?
Can a Specific Capability Replace It?
Can the Architecture Be Changed?

Document your recommendation.

You discover:

cluster-admin

assigned to the workload ServiceAccount.

Determine:

Actual API Requirement
Minimum Resources
Required Verbs
Namespace Scope

Design a least-privilege replacement.

You discover:

hostPath: /

mounted writable.

Assess:

Host Exposure
Potential Impact
Business Requirement
Alternative Storage
Required Containment

Treat this as a high-priority security concern.

You discover:

image: application:latest

Design remediation using:

Controlled Image Version
Trusted Registry
Scanning
Image Verification
Deployment Approval

The application requires writing to:

/tmp

but you want:

readOnlyRootFilesystem: true

Design:

Read-Only Root
+
Writable emptyDir for /tmp

instead of disabling filesystem protection entirely.

The application does not call the Kubernetes API.

Determine whether:

automountServiceAccountToken: false

is appropriate.

Validate application functionality afterward.

A hardened workload stops working after:

capabilities:
drop:
- ALL

Do not simply restore all capabilities.

Determine:

Which Specific Capability Is Required?
Why?
Can Application Design Remove the Requirement?

Then add only the minimum required capability if justified.

A workload cannot run with:

runAsNonRoot: true

Investigate:

Image USER
File Ownership
Port Requirements
Startup Script
Writable Paths

Determine whether the image should be rebuilt.

Your complete Kubernetes security architecture now looks like:

Trusted Source
Secure Build
Image Scanning
Trusted Registry
Admission Policy
Hardened Workload
RBAC
NetworkPolicy
Runtime Detection
Central Logging
Incident Response

No single control is expected to stop every threat.

You have now worked across:

IDENTITY
RBAC
CONFIGURATION
Kyverno / Gatekeeper
NETWORK
NetworkPolicy
WORKLOAD
SecurityContext
RUNTIME
Behavioral Detection
RESPONSE
Investigation and Containment

Capture:

Baseline Deployment
Baseline Security Assessment
Hardened Deployment
Non-Root Validation
Privilege Configuration
Capabilities
Filesystem Configuration
Seccomp Configuration
ServiceAccount
Token Configuration
RBAC Review
Resource Controls
Before/After Comparison
Security Findings
Lab:
Kubernetes Workload Security
Date:
Cluster:
Namespace:
Baseline Workload:
Baseline Risks:
Hardened Workload:
Non-Root:
Pass / Fail
Privilege Escalation:
Pass / Fail
Capabilities:
Pass / Fail
Read-Only Filesystem:
Pass / Fail
Seccomp:
Pass / Fail
Service Account:
Pass / Fail
Token Mount:
Pass / Fail
Resources:
Pass / Fail
Image Review:
Pass / Fail
Security Findings:
Remediation:
Validation:

Score the workload:

Control Pass Fail N/A
Non-root
Privileged disabled
Privilege escalation disabled
Capabilities minimized
Read-only root filesystem
Seccomp
Dedicated ServiceAccount
Least-privilege RBAC
Token mounting controlled
Secrets protected
Resource controls
Image controlled
Network segmentation
Runtime monitoring

Prioritize findings based on:

Exploitability
Privilege
Internet Exposure
Data Sensitivity
Identity Permissions
Network Reachability
Business Criticality
Privileged + Internet-Facing
Critical Attention
Missing Ownership Label
Governance Issue

Both matter, but not equally.

Preserve your evidence first.

Then:

Terminal window
kubectl delete namespace ghc-workload-security

Verify:

Terminal window
kubectl get namespace ghc-workload-security

Restore your normal namespace:

Terminal window
kubectl config set-context --current --namespace=default
  • Assessed baseline workload
  • Reviewed image
  • Reviewed security context
  • Reviewed identity
  • Reviewed resources
  • Reviewed volumes
  • Reviewed network exposure
  • Implemented non-root execution
  • Disabled privileged mode
  • Disabled privilege escalation
  • Dropped unnecessary capabilities
  • Implemented read-only root filesystem
  • Configured explicit writable storage
  • Used seccomp protection
  • Created dedicated ServiceAccount
  • Reviewed RBAC
  • Applied least privilege
  • Disabled unnecessary token mounting
  • Reviewed secret references
  • Avoided hardcoded credentials
  • Understood base64 vs encryption
  • Considered rotation
  • Configured CPU requests
  • Configured memory requests
  • Configured CPU limits
  • Configured memory limits
  • Reviewed image source
  • Avoided uncontrolled mutable tags
  • Understood image digests
  • Understood vulnerability scanning
  • Considered minimal images
  • Understood Pod Security Standards
  • Understood Restricted-style hardening
  • Connected hardening with admission policy
  • Connected hardening with NetworkPolicy
  • Connected hardening with runtime security
  • Created security findings
  • Built before/after comparison
  • Collected evidence
  • Prioritized remediation
  • Designed exception process

You have now worked with:

Kubernetes Workload Security
Container Hardening
Security Contexts
Non-Root Execution
Privilege Management
Linux Capabilities
Filesystem Security
Seccomp
Service Accounts
RBAC
Secrets
Resource Controls
Image Security
Pod Security Standards

These skills are highly relevant for:

Kubernetes Security Engineer
Cloud Security Engineer
DevSecOps Engineer
Platform Security Engineer
Container Security Engineer
Cloud Security Architect
Security Consultant
Kubernetes Administrator
  1. What is Kubernetes workload security?
  2. What is a securityContext?
  3. What is the difference between Pod-level and container-level securityContext?
  4. Why should containers run as non-root?
  5. What does runAsNonRoot do?
  6. Why might an image fail after enabling non-root execution?
  7. What does allowPrivilegeEscalation control?
  8. What is a privileged container?
  9. Why are privileged containers dangerous?
  10. What are Linux capabilities?
  11. Why would you drop all capabilities?
  12. When might a capability need to be added back?
  13. What does readOnlyRootFilesystem do?
  14. Why is a read-only root filesystem useful?
  15. How can an application write temporary data with a read-only root filesystem?
  16. What is seccomp?
  17. What does RuntimeDefault mean conceptually?
  18. Why are host namespaces security-sensitive?
  19. What is hostPath?
  20. Why can writable hostPath volumes be dangerous?
  21. What is a Kubernetes ServiceAccount?
  22. Why should applications use dedicated ServiceAccounts?
  23. Why disable automatic ServiceAccount token mounting?
  24. When does an application need Kubernetes API access?
  25. How does RBAC affect workload security?
  26. Why should workloads not receive cluster-admin?
  27. Why are Kubernetes Secrets not automatically secure simply because values appear base64 encoded?
  28. How should secrets be protected?
  29. Why is secret rotation important?
  30. Why are resource requests security relevant?
  31. Why are resource limits security relevant?
  32. What security risk can uncontrolled resource consumption create?
  33. Why should container images come from trusted registries?
  34. Why can latest be problematic?
  35. What is an image digest?
  36. Why are minimal container images useful?
  37. What is container vulnerability scanning?
  38. What are Pod Security Standards?
  39. What are the three Pod Security Standards levels?
  40. What does Restricted aim to accomplish?
  41. How can Kyverno enforce workload security?
  42. How can Gatekeeper enforce workload security?
  43. How does NetworkPolicy complement workload hardening?
  44. How does runtime monitoring complement workload hardening?
  45. What is defense in depth?
  46. How would you assess a Kubernetes workload?
  47. How would you prioritize workload-security findings?
  48. How should workload exceptions be handled?
  49. What evidence would you collect during a workload-security assessment?
  50. How would you build an enterprise Kubernetes workload-security baseline?

You should now be able to receive:

Deployment Manifest

and review:

IMAGE
IDENTITY
PRIVILEGE
CAPABILITIES
FILESYSTEM
SECCOMP
SECRETS
VOLUMES
RESOURCES
NETWORK
RUNTIME

Then transform:

Functional Workload

into:

Functional
+
Hardened
+
Observable
+
Governed
Workload

You should be able to ask:

If this application
is compromised today...

then determine:

What User Does It Run As?
Can It Escalate?
What Capabilities Does It Have?
What Can It Write?
What Credentials Can It Access?
What Kubernetes Permissions Exist?
What Network Destinations Can It Reach?
Can Suspicious Behavior Be Detected?

This is the core workload-security mindset.

Remember:

ASSUME APPLICATION COMPROMISE
MINIMIZE PRIVILEGE
MINIMIZE IDENTITY
MINIMIZE FILESYSTEM ACCESS
MINIMIZE CREDENTIALS
MINIMIZE NETWORK ACCESS
MONITOR BEHAVIOR
REDUCE BLAST RADIUS

The goal is not to make compromise theoretically impossible.

The goal is to ensure:

One Compromised Application
Does Not Automatically Become
a Compromised Kubernetes Environment.

Before this lab:

You knew how to deploy
and operate Kubernetes workloads.

After this lab:

You assessed insecure workloads,
implemented non-root execution,
restricted privileges,
dropped capabilities,
protected filesystems,
applied seccomp,
secured workload identity,
reduced credential exposure,
implemented resource controls,
reviewed image security,
and validated a hardened workload.

You have moved from:

Running Kubernetes Applications

to:

Running Security-Hardened
Kubernetes Workloads.

You have now completed the Kubernetes security lab sequence:

Lab 01 — Kubernetes Fundamentals
Resource Understanding
Lab 02 — Kubernetes RBAC
Identity Security
Lab 03 — Kyverno
Policy-as-Code
Lab 04 — Network Policies
Network Segmentation
Lab 05 — OPA Gatekeeper
Admission Governance
Lab 06 — Runtime Security
Threat Detection
Lab 07 — Workload Security
Workload Hardening

Together, these labs form:

IDENTITY
+
POLICY
+
NETWORK
+
WORKLOAD
+
RUNTIME

➡️ Runbook 01 — Kubernetes Compliance Assessment

You have learned how individual Kubernetes security controls work.

Now you will move from:

Implementing Individual Controls

to:

Assessing an Entire Kubernetes
Environment Systematically.

The runbook will provide a repeatable professional workflow for reviewing:

Cluster Security
Identity and RBAC
Workload Security
Network Segmentation
Admission Policies
Secrets
Logging
Runtime Security
Security Baselines
Compliance Evidence
Findings
Remediation

The learning progression now becomes:

CERTIFICATIONS
Build Knowledge
LABS
Build Practical Skills
RUNBOOKS
Build Repeatable
Professional Security Operations

You are now ready to move from Kubernetes security practitioner to performing structured Kubernetes security assessments.