Skip to content

Commit 5be3956

Browse files
authored
Merge pull request #64227 from bergerhoffer/OSDOCS-7527
OSDOCS#7527: Adding more info about PSA, including namespaces that ar…
2 parents 8986f07 + ff2f9ef commit 5be3956

5 files changed

+106
-5
lines changed

authentication/understanding-and-managing-pod-security-admission.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ toc::[]
88

99
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.
1010

11+
// About pod security admission
12+
include::modules/security-context-constraints-psa-about.adoc[leveloffset=+1]
13+
1114
// Security context constraint synchronization with pod security standards
1215
include::modules/security-context-constraints-psa-synchronization.adoc[leveloffset=+1]
1316

1417
// Controlling pod security admission synchronization
1518
include::modules/security-context-constraints-psa-opting.adoc[leveloffset=+1]
1619

20+
// Configuring pod security admission for a namespace
21+
include::modules/security-context-constraints-psa-label.adoc[leveloffset=+1]
22+
1723
// About pod security admission alerts
1824
include::modules/security-context-constraints-psa-rectifying.adoc[leveloffset=+1]
1925

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * authentication/understanding-and-managing-pod-security-admission.adoc
4+
// * operators/operator_sdk/osdk-complying-with-psa.adoc
5+
6+
:_content-type: CONCEPT
7+
[id="security-context-constraints-psa-about_{context}"]
8+
= About pod security admission
9+
10+
{product-title} includes link:https://kubernetes.io/docs/concepts/security/pod-security-admission[Kubernetes pod security admission]. Pods that do not comply with the pod security admission defined globally or at the namespace level are not admitted to the cluster and cannot run.
11+
12+
Globally, the `privileged` profile is enforced, and the `restricted` profile is used for warnings and audits.
13+
14+
You can also configure the pod security admission settings at the namespace level.
15+
16+
[id="psa-modes_{context}"]
17+
== Pod security admission modes
18+
19+
You can configure the following pod security admission modes for a namespace:
20+
21+
.Pod security admission modes
22+
[cols="1,2,3a",options="header"]
23+
|===
24+
|Mode
25+
|Label
26+
|Description
27+
28+
|`enforce`
29+
|`pod-security.kubernetes.io/enforce`
30+
|Rejects a pod from admission if it does not comply with the set profile
31+
32+
|`audit`
33+
|`pod-security.kubernetes.io/audit`
34+
|Logs audit events if a pod does not comply with the set profile
35+
36+
|`warn`
37+
|`pod-security.kubernetes.io/warn`
38+
|Displays warnings if a pod does not comply with the set profile
39+
|===
40+
41+
[id="psa-profiles_{context}"]
42+
== Pod security admission profiles
43+
44+
You can set each of the pod security admission modes to one of the following profiles:
45+
46+
.Pod security admission profiles
47+
[cols="1,3a",options="header"]
48+
|===
49+
|Profile
50+
|Description
51+
52+
|`privileged`
53+
|Least restrictive policy; allows for known privilege escalation
54+
55+
|`baseline`
56+
|Minimally restrictive policy; prevents known privilege escalations
57+
58+
|`restricted`
59+
|Most restrictive policy; follows current pod hardening best practices
60+
|===
61+
62+
[id="psa-privileged-namespaces_{context}"]
63+
== Privileged namespaces
64+
65+
The following system namespaces are always set to the `privileged` pod security admission profile:
66+
67+
* `default`
68+
* `kube-public`
69+
* `kube-system`
70+
71+
You cannot change the pod security profile for these privileged namespaces.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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-label_{context}"]
7+
= Configuring pod security admission for a namespace
8+
9+
You can configure the pod security admission settings at the namespace level. For each of the pod security admission modes on the namespace, you can set which pod security admission profile to use.
10+
11+
.Procedure
12+
13+
* For each pod security admission mode that you want to set on a namespace, run the following command:
14+
15+
+
16+
[source,terminal]
17+
----
18+
$ oc label namespace <namespace> \ <1>
19+
pod-security.kubernetes.io/<mode>=<profile> \ <2>
20+
--overwrite
21+
----
22+
<1> Set `<namespace>` to the namespace to configure.
23+
<2> Set `<mode>` to `enforce`, `warn`, or `audit`. Set `<profile>` to `restricted`, `baseline`, or `privileged`.

modules/security-context-constraints-psa-synchronization.adoc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@
77
[id="security-context-constraints-psa-synchronization_{context}"]
88
= Security context constraint synchronization with pod security standards
99

10-
{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.
11-
12-
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.
10+
In addition to the global pod security admission control configuration, a controller 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.
1311

1412
[IMPORTANT]
1513
====
16-
Namespaces that are defined as part of the cluster payload have pod security admission synchronization disabled permanently. You can enable pod security admission synchronization on other namespaces as necessary. If an Operator is installed in a user-created `openshift-*` namespace, synchronization is turned on by default after a cluster service version (CSV) is created in the namespace.
14+
Namespaces that are defined as part of the cluster payload have pod security admission synchronization disabled permanently. You can enable pod security admission synchronization on other namespaces as necessary. If an Operator is installed in a user-created `openshift-*` namespace, synchronization is turned on by default after a cluster service version (CSV) is created in the namespace.
1715
====
1816

19-
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.
17+
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 in the namespace to prevent displaying warnings and logging audit events when pods are created.
2018

2119
Namespace labeling is based on consideration of namespace-local service account privileges.
2220

operators/operator_sdk/osdk-complying-with-psa.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ If your Operator project does not require escalated permissions to run, you can
1616
1717
For more information, see xref:../../authentication/understanding-and-managing-pod-security-admission.adoc#understanding-and-managing-pod-security-admission[Understanding and managing pod security admission].
1818

19+
// About pod security admission
20+
include::modules/security-context-constraints-psa-about.adoc[leveloffset=+1]
21+
1922
include::modules/security-context-constraints-psa-synchronization.adoc[leveloffset=+1]
2023
include::modules/osdk-ensuring-operator-workloads-run-restricted-psa.adoc[leveloffset=+1]
2124

0 commit comments

Comments
 (0)