Part IV — Expert Production Engineering · Chapter 22 · Lesson 2 of 5 · 2 min read
Lesson 2: Non-Root Execution, Read-Only Filesystems, seccomp, and Dropped Capabilities
Lesson level: Expert
Purpose: Harden the operating environment while preserving narrowly scoped required writes. Non-root execution does not replace least-privilege host integration.
Learning Objectives
- Explain the relevant resource and security contracts.
- Review generated defaults against the application requirements.
- Validate normal and failure behavior in an approved environment.
2.1 Concepts
The secure generator disables privilege escalation, uses a non-root user and group, makes the root filesystem read-only, drops ALL Linux capabilities, and selects RuntimeDefault seccomp. These are container controls, not language permissions. PeaLang capability restrictions must still be configured independently. A /tmp emptyDir permits transient writes; durable audits and model state need explicitly approved storage and access policies.
2.2 Annotated Example
SecureKubernetesConfig defaults to user and group 10001. Its generated container securityContext includes runAsNonRoot, readOnlyRootFilesystem, allowPrivilegeEscalation=False, capabilities.drop=["ALL"], and seccompProfile.type="RuntimeDefault". The default image label references an older release, so supply the actual approved RC2 image explicitly. Ensure it contains the optional serving dependencies and has the required readable artifacts.
2.3 Guided Practice
List each filesystem path used by the application: immutable model, transient decrypted material, audit database, logs, and caches. Decide which paths can be read-only, ephemeral, or durable and who can read them.
2.4 Common Mistakes
Do not restore root privileges to repair file permissions, expose private signing keys to serving Pods, or assume runtime seccomp constrains arbitrary application data access.
2.5 Hands-On Lab
- Start the approved test image under the generated non-root identity and confirm pipeline loading.
- Attempt a harmless write to the read-only application directory and confirm denial.
- Verify the permitted temporary path and remove decrypted test artifacts after use.
- Test audit and logging destinations without widening unrelated permissions.
Deliverable: Reviewed resources, environment prerequisites, test results, and unresolved operational gaps.
2.6 Review Questions
Why are container controls separate from script capabilities? Which writes fail under a read-only root filesystem? Why must the default image be overridden?
2.7 Applied Challenge
Create a writable-path inventory and evidence record for every mounted volume, including ownership, retention, encryption requirements, and recovery policy.
Lesson Summary
Harden the operating environment while preserving narrowly scoped required writes. Non-root execution does not replace least-privilege host integration.
Lesson status: Draft complete; ready for review. Source-checked, not cluster-validated.