You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: enhancements/authentication/pod-security-admission-enforcement.md
+31-21
Original file line number
Diff line number
Diff line change
@@ -27,44 +27,42 @@ superseded-by: []
27
27
28
28
This enhancement introduces a **new cluster-scoped API**, changes to the relevant controllers and to the `OpenShiftPodSecurityAdmission``FeatureGate` to gradually roll out [Pod Security Admission (PSA)](https://kubernetes.io/docs/concepts/security/pod-security-admission/) enforcement [in OpenShift](https://www.redhat.com/en/blog/pod-security-admission-in-openshift-4.11).
29
29
Enforcement means that the `PodSecurityAdmissionLabelSynchronizationController` sets the `pod-security.kubernetes.io/enforce` label on Namespaces, and the PodSecurityAdmission plugin enforces the `Restricted`[Pod Security Standard (PSS)](https://kubernetes.io/docs/concepts/security/pod-security-standards/).
30
-
By “gradually,” it means that these changes happen in separate steps.
30
+
By “gradually”, it means that these changes happen in separate steps.
31
31
32
32
The new API offers users the option to manipulate the outcome by enforcing the `Privileged` or `Restricted` PSS directly.
33
33
The suggested default decision is `Conditional`, which only progresses if no potentially failing workloads are found.
34
-
The progression starts with the `PodSecurityAdmissionLabelSynchronizationController` labeling **Namespaces**for enforcement and finishes with the **Global Configuration** of `PodSecurity` being set to `Restricted` by default.
34
+
The progression starts with the `PodSecurityAdmissionLabelSynchronizationController` labeling **Namespaces** and finishes with the **Global Configuration**.
35
35
36
36
This enhancement expands the ["PodSecurity admission in OpenShift"](https://github.com/openshift/enhancements/blob/61581dcd985130357d6e4b0e72b87ee35394bf6e/enhancements/authentication/pod-security-admission.md) and ["Pod Security Admission Autolabeling"](https://github.com/openshift/enhancements/blob/61581dcd985130357d6e4b0e72b87ee35394bf6e/enhancements/authentication/pod-security-admission-autolabeling.md) enhancements.
37
37
38
38
## Motivation
39
39
40
40
After introducing Pod Security Admission and Autolabeling based on SCCs, some clusters were found to have Namespaces with Pod Security violations.
41
-
Over the last few releases, the number of clusters with failing workloads has dropped significantly.
41
+
Over the last few releases, the number of clusters with violating workloads has dropped significantly.
42
42
Although these numbers are now quite low, it is essential to avoid any scenario where users end up with failing workloads.
43
43
To ensure a smooth and safe transition, this proposal uses a gradual, conditional rollout based on the new API.
44
44
This approach also provides an overview of which Namespaces could contain failing workloads.
45
45
46
46
### Goals
47
47
48
-
1.Start the process of rolling out Pod Security Admission enforcement.
48
+
1.Rolling out Pod Security Admission enforcement.
49
49
2. Minimize the risk of breakage for existing workloads.
50
50
3. Allow users to remain in “privileged” mode for a couple of releases.
51
51
52
52
### Non-Goals
53
53
54
54
1. Enabling the PSA label-syncer to evaluate workloads with user-based SCC decisions.
55
55
2. Providing a detailed list of every Pod Security violation in a Namespace.
56
-
3.Allowing the user to move from enforcing the global config to relying solely on the PSA label syncer to set the `enforce` label.
56
+
3.Moving seamlessly between different progressions back and forth.
57
57
58
58
## Proposal
59
59
60
-
This section outlines the necessary changes for a safe, stepwise rollout of Pod Security Admission enforcement.
61
-
62
60
### User Stories
63
61
64
62
As a System Administrator:
65
63
- I want to transition to enforcing Pod Security Admission only if the cluster would have no failing workloads.
66
-
- If there are workloads in certain Namespaces that would fail under enforcement, I want to be able to identify which Namespaces need to be fixed.
67
-
- If I encounter issues with the Pod Security Admission transition, I want to opt out (remain privileged) across my clusters until I can fix the issues.
64
+
- If there are workloads in certain Namespaces that would fail under enforcement, I want to be able to identify which Namespaces need to be investigated.
65
+
- If I encounter issues with the Pod Security Admission transition, I want to opt out (remain privileged) across my clusters until later.
68
66
69
67
### Current State
70
68
@@ -86,13 +84,14 @@ To allow a safer rollout of enforcement, the following steps are proposed:
86
84
87
85
The feature flag `OpenShiftPodSecurityAdmission` being enabled is a pre-condition for this process to start.
88
86
It will also serve as a break-glass option.
89
-
If unexpected failures occur, the rollout will be reverted by removing the `FeatureGate` from the default `FeatureSet`.
87
+
If the progression causes failures for users, the rollout will be reverted by removing the `FeatureGate` from the default `FeatureSet`.
90
88
91
89
#### Examples
92
90
91
+
Examples of failing workloads include:
92
+
93
93
-**Category 1**: Namespaces with workloads that use user-bound SCCs (workloads created directly by a user) without meeting the `Restricted` PSS.
94
94
-**Category 2**: Namespaces that do not have the `pod-security.kubernetes.io/enforce` label and whose workloads would not satisfy the `Restricted` PSS.
95
-
96
95
Possible cases include:
97
96
1. Namespaces with `security.openshift.io/scc.podSecurityLabelSync: "false"` and no `pod-security.kubernetes.io/enforce` label set.
98
97
2.`openshift-` prefixed Namespaces (not necessarily created or managed by OpenShift teams).
@@ -109,7 +108,7 @@ It will let administrators:
109
108
### Release Timing
110
109
111
110
The gradual process will span three releases:
112
-
-**Release `n-1`**: Introduce the new API, diagnostics for identifying violating Namespaces, and enable the PSA label syncer to remove enforce labels from release `n`.
111
+
-**Release `n-1`**: Introduce the new API, improve diagnostics for identifying violating Namespaces and enable the PSA label syncer to remove enforce labels from its release `n` version.
113
112
-**Release `n`**: Permit the `PodSecurityAdmissionLabelSynchronizationController` to set enforce labels if there are no workloads that would fail.
114
113
-**Release `n+2`**: Enable the PodSecurity configuration to enforce `restricted` if there are no workloads that would fail.
115
114
@@ -126,7 +125,7 @@ Additional diagnostics are required to confirm the full set of potential causes.
126
125
127
126
#### New SCC Annotation: `security.openshift.io/ValidatedSCCSubjectType`
128
127
129
-
The annotation `openshift.io/scc` currently indicates which SCC admitted a workload, but it does not distinguish **how** the SCC was granted—whether through a user or a Pod’s ServiceAccount.
128
+
The annotation `openshift.io/scc` currently indicates which SCC admitted a workload, but it does not distinguish **how** the SCC was granted — whether through a user or a Pod’s ServiceAccount.
130
129
A new annotation will help determine if a ServiceAccount with the required SCCs was used, or if a user created the workload out of band.
131
130
Because the PSA label syncer does not track user-based SCCs itself, it cannot fully assess labeling under those circumstances.
132
131
@@ -177,8 +176,8 @@ import (
177
176
// in the cluster. Unlike PSATargetMode, which reflects the user’s desired or “target”
178
177
// setting, PSAEnforcementMode describes the effective mode currently active.
179
178
//
180
-
// The modes define a progression from no enforcement, to label-based enforcement,
181
-
// to label-based plus global config enforcement. enforcement mode for Pod Security Admission rollout.
179
+
// The modes define a progression from no enforcement, through label-based enforcement
180
+
// to label-based with global config enforcement.
182
181
typePSAEnforcementModestring
183
182
184
183
const (
@@ -213,7 +212,7 @@ const (
213
212
214
213
// TargetModeConditional indicates that the user is willing to let the cluster
215
214
// automatically enforce a stricter enforcement once there are no violating Namespaces.
216
-
// If violations exist, the cluster stays in "Privileged" until those are resolved.
215
+
// If violations exist, the cluster stays in its previous state until those are resolved.
217
216
// This allows a gradual move towards label and global config enforcement without
218
217
// immediately breaking workloads that are not yet compliant.
// violatingNamespaces is a list of namespaces that can initially block the
262
265
// cluster from fully enforcing a "Restricted" mode. Administrators should
263
266
// review each listed Namespace to fix any issues to enable strict enforcement.
264
267
//
265
-
// If a cluster is already in "Restricted" mode and new violations emerge,
268
+
// If a cluster is already in a more "Restricted" mode and new violations emerge,
266
269
// it remains in "Restricted" until the user explicitly switches to
267
270
// "spec.mode = Privileged".
268
271
//
@@ -328,7 +331,7 @@ Below is a table illustrating the expected behavior when the `FeatureGate` `Open
328
331
329
332
A cluster that uses `spec.targetMode = Conditional` can revert to `Privileged` only if the user explicitly sets `spec.targetMode = Privileged`.
330
333
A cluster in `spec.mode = Conditional` that starts with `status.EnforcementMode = Privileged` may switch to a more restrictive enforcement mode as soon as there are no violations.
331
-
To manage the timing of this rollout, an administrator can set `spec.mode = Privileged` and later switch it to Conditional when ready.
334
+
To manage the timing of this rollout, an administrator can set `spec.mode = Privileged` and later switch it to `Conditional` when ready.
332
335
333
336
`status.violatingNamespaces` lists the Namespaces that would fail if `status.enforcementMode` were `LabelEnforcement` or `FullEnforcement`.
334
337
The reason field helps identify whether the PSA label syncer or the PodSecurity config is the root cause.
@@ -337,8 +340,15 @@ Administrators must query the kube-apiserver (or use the [cluster debugging tool
337
340
### Implementation Details
338
341
339
342
- The `PodSecurityReadinessController` in the `cluster-kube-apiserver-operator` will manage the new API.
340
-
- If the `FeatureGate` is removed, the cluster must revert to its previous state.
341
-
- The [`Config Observer controller`](https://github.com/openshift/cluster-kube-apiserver-operator/blob/218530fdea4e89b93bc6e136d8b5d8c3beacdd51/pkg/operator/configobservation/configobservercontroller/observe_config_controller.go#L131) must be updated for the `PodSecurity` configuration.
343
+
- If the `FeatureGate` is removed from the current `FeatureSet`, the cluster must revert to its previous state.
344
+
- The [`Config Observer Controller`](https://github.com/openshift/cluster-kube-apiserver-operator/blob/218530fdea4e89b93bc6e136d8b5d8c3beacdd51/pkg/operator/configobservation/configobservercontroller/observe_config_controller.go#L131) must be updated to watch for the new API alongside the `FeatureGate`.
345
+
346
+
#### PodSecurityReadinessController
347
+
348
+
The `PodSecurityReadinessController` will manage the `PSAEnforcementConfig` API.
349
+
It already collects most of the necessary data to determine whether a Namespace would fail enforcement or not to create a [`ClusterFleetEvaluation`](https://github.com/openshift/enhancements/blob/master/dev-guide/cluster-fleet-evaluation.md).
350
+
With the `security.openshift.io/MinimallySufficientPodSecurityStandard`, it will be able to evaluate all Namespaces for failing workloads, if any enforcement would happen.
351
+
With the `security.openshift.io/ValidatedSCCSubjectType`, it can categorize violations more accurately and create a more accurate `ClusterFleetEvaluation`.
342
352
343
353
#### PodSecurity Configuration
344
354
@@ -349,7 +359,7 @@ It must watch both the `status.enforcementMode` and the `FeatureGate` to make de
349
359
350
360
The PSA label syncer will watch the `status.enforcementMode` and the `OpenShiftPodSecurityAdmission` feature gate.
351
361
If `status.enforcementMode` is `LabelEnforcement` or `FullEnforcement` and `OpenShiftPodSecurityAdmission` is enabled, the syncer will set the `pod-security.kubernetes.io/enforce` label.
352
-
Otherwise, it will refrain from setting that label and remove any enforce labels it owns.
362
+
Otherwise, it will refrain from setting that label and remove any enforce labels it owns if existent.
353
363
354
364
Because the ability to set `pod-security.kubernetes.io/enforce` is introduced in release `n`, the ability to remove that label must exist in release `n-1`.
355
365
Otherwise, the cluster will be unable to revert to its previous state.
0 commit comments