What does a hardened `securityContext` look like?
BeginnerConceptKubernetes Security
Answer
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10001
fsGroup: 10001
seccompProfile: { type: RuntimeDefault }
containers:
- name: api
image: ghcr.io/acme/api@sha256:...
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities: { drop: ["ALL"] }
This passes the restricted profile. readOnlyRootFilesystem stops attackers dropping tools on disk; mount an emptyDir at /tmp if the app needs scratch space.
More on Kubernetes Security
What are the 4Cs of cloud native security?BeginnerWhat happens to a request between `kubectl apply` and etcd from a security point of view?IntermediateExplain Role, ClusterRole, RoleBinding and ClusterRoleBinding.BeginnerHow do you check what a user or service account is allowed to do?BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedHow do service account tokens work now, and what is `automountServiceAccountToken`?Intermediate