System Administration
medium

Questão de System Administration #019e3a4f

Enunciado da Questão
System Administration
#security context
#security profile
#kubernetes
#pod security
Médio

What's the difference between a security profile and a security context?

A

Security Contexts configure Clusters and Namespaces at runtime. Security profiles are control plane mechanisms to enforce specific settings in the Security Context.

B

Security Contexts configure Pods and Containers at runtime. Security profiles are control plane mechanisms to enforce specific settings in the Security Context.

Correta
C

Security Profiles configure Pods and Containers at runtime. Security Contexts are control plane mechanisms to enforce specific settings in the Security Profile.

D

Security Profiles configure Clusters and Namespaces at runtime. Security Contexts are control plane mechanisms to enforce specific settings in the Security Profile.

Explicação Oficial / Explicações da Comunidade

Summary

A Security Context defines privilege and access control settings for Pods and Containers at runtime, such as user IDs, groups, SELinux options, and capabilities. A Security Profile is a control plane mechanism (e.g., Pod Security Standards or custom admission controllers) that enforces specific settings in the Security Context, ensuring compliance with organizational policies.

How It Works

  • Security Context: Configured at the Pod or Container level in the Pod spec (.spec.securityContext). It applies directly to the running processes, controlling Linux capabilities, runAsUser, fsGroup, seLinuxOptions, etc. It is a runtime attribute.
  • Security Profile: A higher-level policy object (e.g., PodSecurityPolicy, OPA Gatekeeper constraints, or Kyverno policies) that validates or mutates Pods during admission. It enforces that Security Contexts meet certain criteria (e.g., disallow privileged containers, require read-only root filesystem). Profiles are control plane mechanisms that operate before the Pod is created.

Why the Correct Answer is Right

The correct statement is: "Security Contexts configure Pods and Containers at runtime. Security profiles are control plane mechanisms to enforce specific settings in the Security Context." This accurately reflects that Security Contexts are runtime configurations applied to individual Pods/Containers, while Security Profiles are admission-time policies that enforce constraints on those Security Contexts.

Why the Incorrect Answers are Wrong

  • The statement that Security Contexts configure Clusters and Namespaces is incorrect; Security Contexts are Pod/Container-level, not cluster/namespace-level. Cluster-level security is handled by other resources like RBAC, NetworkPolicies, or PodSecurityAdmission.
  • The statement that Security Profiles configure Pods and Containers at runtime is incorrect; Security Profiles are not runtime configurations but admission control policies. They do not directly configure Pods; they enforce rules on Security Contexts.
  • The statement that Security Contexts are control plane mechanisms is incorrect; Security Contexts are runtime attributes, not control plane policies. The control plane enforces policies via Security Profiles.
  • The statement that Security Profiles configure Clusters and Namespaces is misleading; while profiles can be applied at namespace scope, they do not configure clusters/namespaces themselves—they enforce constraints on Pod Security Contexts.