Skip to content

Commit 87a732c

Browse files
authored
Merge pull request #48409 from bergerhoffer/pr-47647
AUTH-133: Pod security admission
2 parents 4c30345 + ceb9a44 commit 87a732c

6 files changed

+141
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,9 @@ Topics:
939939
- Name: Managing security context constraints
940940
File: managing-security-context-constraints
941941
Distros: openshift-enterprise,openshift-origin
942+
- Name: Understanding and managing pod security admission
943+
File: understanding-and-managing-pod-security-admission
944+
Distros: openshift-enterprise,openshift-origin
942945
- Name: Impersonating the system:admin user
943946
File: impersonating-system-admin
944947
Distros: openshift-enterprise,openshift-origin
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
:_content-type: ASSEMBLY
2+
[id="understanding-and-managing-pod-security-admission"]
3+
= Understanding and managing pod security admission
4+
include::_attributes/common-attributes.adoc[]
5+
:context: understanding-and-managing-pod-security-admission
6+
7+
toc::[]
8+
9+
Pod security admission is an implementation of the link:https://kubernetes.io/docs/concepts/security/pod-security-standards/[Kubernetes pod security standards]. Use pod security admission to restrict the behavior of pods.
10+
11+
include::modules/security-context-constraints-psa-synchronization.adoc[leveloffset=+1]
12+
13+
include::modules/security-context-constraints-psa-opting.adoc[leveloffset=+1]
14+
15+
include::modules/security-context-constraints-psa-rectifying.adoc[leveloffset=+1]
16+
17+
[role="_additional-resources"]
18+
[id="additional-resources_managing-pod-security-admission"]
19+
== Additional resources
20+
21+
* xref:../security/audit-log-view.adoc#nodes-nodes-audit-log-basic-viewing_audit-log-view[Viewing audit logs]
22+
* xref:../authentication/managing-security-context-constraints.adoc#managing-pod-security-policies[Managing security context constraints]

modules/security-context-constraints-about.adoc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ This SCC allows host file system access as any UID, including UID 0. Grant with
7575
If additional workloads are run on control plane hosts, use caution when providing access to `hostnetwork`. A workload that runs `hostnetwork` on a control plane host is effectively root on the cluster and must be trusted accordingly.
7676
====
7777

78+
|`hostnetwork-v2`
79+
| Like the `hostnetwork` SCC, but with the following differences:
80+
81+
* `ALL` capabilities are dropped from containers.
82+
* The `NET_BIND_SERVICE` capability can be added explicitly.
83+
* `seccompProfile` is set to `runtime/default` by default.
84+
* `allowPrivilegeEscalation` must be unset or set to `false` in security contexts.
85+
7886
|`node-exporter`
7987
|Used for the Prometheus node exporter.
8088

@@ -87,6 +95,14 @@ endif::[]
8795
|`nonroot`
8896
|Provides all features of the `restricted` SCC, but allows users to run with any non-root UID. The user must specify the UID or it must be specified in the manifest of the container runtime.
8997

98+
|`nonroot-v2`
99+
| Like the `nonroot` SCC, but with the following differences:
100+
101+
* `ALL` capabilities are dropped from containers.
102+
* The `NET_BIND_SERVICE` capability can be added explicitly.
103+
* `seccompProfile` is set to `runtime/default` by default.
104+
* `allowPrivilegeEscalation` must be unset or set to `false` in security contexts.
105+
90106
ifndef::openshift-dedicated[]
91107
|`privileged`
92108
|Allows access to all privileged and host features and the ability to run as any user, any group, any FSGroup, and with any SELinux context.
@@ -132,6 +148,14 @@ The `restricted` SCC:
132148
The restricted SCC is the most restrictive of the SCCs that ship by default with the system. However, you can create a custom SCC that is even more restrictive. For example, you can create an SCC that restricts `readOnlyRootFS` to `true` and `allowPrivilegeEscalation` to `false`.
133149
====
134150

151+
|`restricted-v2`
152+
| Like the `restricted` SCC, but with the following differences:
153+
154+
* `ALL` capabilities are dropped from containers.
155+
* The `NET_BIND_SERVICE` capability can be added explicitly.
156+
* `seccompProfile` is set to `runtime/default` by default.
157+
* `allowPrivilegeEscalation` must be unset or set to `false` in security contexts.
158+
135159
|===
136160

137161
[id="scc-settings_{context}"]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * authentication/understanding-and-managing-pod-security-admission.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="security-context-constraints-psa-opting_{context}"]
7+
= Controlling pod security admission synchronization
8+
9+
You can enable or disable automatic pod security admission synchronization for most namespaces.
10+
11+
[NOTE]
12+
====
13+
By default, user-created namespaces that have the prefix `openshift-` have pod security admission label synchronization disabled.
14+
15+
Namespaces that the installer creates have pod security admission label synchronization disabled permanently. These namespaces include:
16+
17+
* All namespaces that are prefixed with `openshift-`, except for `openshift-operators`
18+
* `default`
19+
* `kube-node-lease`
20+
* `kube-system`
21+
* `kube-public`
22+
* `openshift`
23+
====
24+
25+
.Procedure
26+
27+
* For each namespace that you want to configure, set a value for the `security.openshift.io/scc.podSecurityLabelSync` label:
28+
** To disable pod security admission label sychronization in a namespace, set the value of the `security.openshift.io/scc.podSecurityLabelSync` label to `false`.
29+
+
30+
Run the following command:
31+
+
32+
[source,terminal]
33+
----
34+
$ oc label namespace <namespace> security.openshift.io/scc.podSecurityLabelSync=false
35+
----
36+
37+
** To enable pod security admission label sychronization in a namespace, set the value of the `security.openshift.io/scc.podSecurityLabelSync` label to `true`.
38+
+
39+
Run the following command:
40+
+
41+
[source,terminal]
42+
----
43+
$ oc label namespace <namespace> security.openshift.io/scc.podSecurityLabelSync=true
44+
----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * authentication/understanding-and-managing-pod-security-admission.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="security-context-constraints-psa-rectifying_{context}"]
7+
= About pod security admission alerts
8+
9+
A `PodSecurityViolation` alert is triggered when the Kubernetes API server reports that there is a pod denial on the audit level of the pod security admission controller. This alert persists for one day.
10+
11+
View the Kubernetes API server audit logs to investigate alerts that were triggered. As an example, a workload is likely to fail admission if global enforcement is set to the `restricted` pod security level.
12+
13+
For assistance in identifying pod security admission violation audit events, see link:https://kubernetes.io/docs/reference/labels-annotations-taints/audit-annotations/#pod-security-kubernetes-io-audit-violations[Audit annotations] in the Kubernetes documentation.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * authentication/understanding-and-managing-pod-security-admission.adoc
4+
5+
:_content-type: CONCEPT
6+
[id="security-context-constraints-psa-synchronization_{context}"]
7+
= Security context constraint synchronization with pod security standards
8+
9+
{product-title} includes link:https://kubernetes.io/docs/concepts/security/pod-security-admission[Kubernetes pod security admission]. Globally, the `privileged` profile is enforced, and the `restricted` profile is used for warnings and audits.
10+
11+
In addition to the global pod security admission control configuration, a controller exists that applies pod security admission control `warn` and `audit` labels to namespaces according to the SCC permissions of the service accounts that are in a given namespace.
12+
13+
The controller examines `ServiceAccount` object permissions to use security context constraints in each namespace. Security context constraints (SCCs) are mapped to pod security profiles based on their field values; the controller uses these translated profiles. Pod security admission `warn` and `audit` labels are set to the most privileged pod security profile found in the namespace to prevent warnings and audit logging as pods are created.
14+
15+
Namespace labeling is based on consideration of namespace-local service account privileges.
16+
17+
Applying pods directly might use the SCC privileges of the user who runs the pod. However, user privileges are not considered during automatic labeling.
18+
19+
[IMPORTANT]
20+
====
21+
Namespaces that have an `openshift-` name prefix and were not created by the system during the installation are not synchronized by default.
22+
23+
Namespaces that have the `openshift-` prefix are typically system namespaces; by convention, a controller should exist to manage them.
24+
25+
You can enable SCC synchronization in namespaces that have the `openshift-` prefix by setting the value of the `security.openshift.io/scc.podSecurityLabelSync` label to `true`.
26+
27+
Namespaces that are defined as part of the cluster payload have pod security admission synchronization disabled permanently. These namespaces include:
28+
29+
* All namespaces that are prefixed with `openshift-`, except for `openshift-operators`
30+
* `default`
31+
* `kube-node-lease`
32+
* `kube-system`
33+
* `kube-public`
34+
* `openshift`
35+
====

0 commit comments

Comments
 (0)