securityContext
The part of a Kubernetes pod or container spec that sets security options such as user, capabilities, seccomp and read-only root filesystem.
In more detail
Settings on a container override the same settings on the pod. Pod Security Standards are checked against these fields.
Examples
kubectl get pod hardened-web -o yaml | grep runAsNonRoot"securityContext": {"runAsNonRoot": true, "seccompProfile": {"type": "RuntimeDefault"}}"capabilities": {"drop": ["ALL"], "add": ["NET_BIND_SERVICE"]}Related terms
- runAsNonRoot — A Kubernetes security setting that, when set to true, stops a container from starting if it would run as the root user.
- allowPrivilegeEscalation — A securityContext setting that, when false, sets no_new_privs so a process cannot gain privileges through setuid programs or file capabilities.
- seccomp — A Linux kernel feature that blocks a process from making system calls it has no need for.
- Pod Security Standards — Three built-in Kubernetes security profiles, called privileged, baseline and restricted, that define how locked down a pod must be.
- Linux capabilities — Separate pieces of root power, such as binding low ports or changing file owners, that can be granted or removed one by one.
- privileged container — A container started with --privileged, which removes almost all isolation and gives it the powers of root on the host.
- non-root user — An ordinary user account with limited rights, which a container should run its service as.
- no-new-privileges — A container setting that stops processes from gaining more rights than they started with, for example by running a program that is marked to run as its owner.
- read-only root filesystem — Running a container so that nothing in its root filesystem can be changed, with writable space only where you add it.
Taught in
- Two Hours, Twenty Tasks: Exam Strategy — Certified Kubernetes Application Developer (CKAD) Exam Prep
- SecurityContexts And Capabilities — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Configuration And Security: Timed Drill And Checkpoint — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Mock Exam: Sixteen Tasks Against The Clock — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Seccomp: Which Syscalls A Container May Make — Certified Kubernetes Security Specialist (CKS) Exam Prep
- AppArmor: The Guard Docker Desktop Does Not Have — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Static Analysis: kubesec And KubeLinter — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Immutable Containers: Read-Only At Runtime — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Kubernetes Pod Security Standards: Baseline & Restricted — Cloud Security & DevSecOps Engineering
- Security Frameworks: NIST CSF 2.0, ISO 27001 & CIS — Cybersecurity Fundamentals, GRC & Cryptography
- From Local Containers To Kubernetes — Docker Architecture & Production Containers
- A Pod That Mounts The Node: Runtime, Pods And Storage — Kubernetes and Cloud Native Security Associate (KCSA) Exam Prep
- Created, But Never Running: Pod Security Admission — Kubernetes and Cloud Native Security Associate (KCSA) Exam Prep
- RBAC: Roles, Bindings And Least Privilege — Kubernetes: Production-Grade Container Orchestration
- securityContext: Nonroot, Capabilities And Seccomp — Kubernetes: Production-Grade Container Orchestration
- Pod Security Admission And Pod Security Standards — Kubernetes: Production-Grade Container Orchestration