Skip to content

Commit 12f022d

Browse files
committed
second iteration - laster iteration
1 parent 176c84b commit 12f022d

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

Diff for: enhancements/authentication/pod-security-admission-enforcement.md

+31-21
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,42 @@ superseded-by: []
2727

2828
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).
2929
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.
3131

3232
The new API offers users the option to manipulate the outcome by enforcing the `Privileged` or `Restricted` PSS directly.
3333
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**.
3535

3636
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.
3737

3838
## Motivation
3939

4040
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.
4242
Although these numbers are now quite low, it is essential to avoid any scenario where users end up with failing workloads.
4343
To ensure a smooth and safe transition, this proposal uses a gradual, conditional rollout based on the new API.
4444
This approach also provides an overview of which Namespaces could contain failing workloads.
4545

4646
### Goals
4747

48-
1. Start the process of rolling out Pod Security Admission enforcement.
48+
1. Rolling out Pod Security Admission enforcement.
4949
2. Minimize the risk of breakage for existing workloads.
5050
3. Allow users to remain in “privileged” mode for a couple of releases.
5151

5252
### Non-Goals
5353

5454
1. Enabling the PSA label-syncer to evaluate workloads with user-based SCC decisions.
5555
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.
5757

5858
## Proposal
5959

60-
This section outlines the necessary changes for a safe, stepwise rollout of Pod Security Admission enforcement.
61-
6260
### User Stories
6361

6462
As a System Administrator:
6563
- 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.
6866

6967
### Current State
7068

@@ -86,13 +84,14 @@ To allow a safer rollout of enforcement, the following steps are proposed:
8684

8785
The feature flag `OpenShiftPodSecurityAdmission` being enabled is a pre-condition for this process to start.
8886
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`.
9088

9189
#### Examples
9290

91+
Examples of failing workloads include:
92+
9393
- **Category 1**: Namespaces with workloads that use user-bound SCCs (workloads created directly by a user) without meeting the `Restricted` PSS.
9494
- **Category 2**: Namespaces that do not have the `pod-security.kubernetes.io/enforce` label and whose workloads would not satisfy the `Restricted` PSS.
95-
9695
Possible cases include:
9796
1. Namespaces with `security.openshift.io/scc.podSecurityLabelSync: "false"` and no `pod-security.kubernetes.io/enforce` label set.
9897
2. `openshift-` prefixed Namespaces (not necessarily created or managed by OpenShift teams).
@@ -109,7 +108,7 @@ It will let administrators:
109108
### Release Timing
110109

111110
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.
113112
- **Release `n`**: Permit the `PodSecurityAdmissionLabelSynchronizationController` to set enforce labels if there are no workloads that would fail.
114113
- **Release `n+2`**: Enable the PodSecurity configuration to enforce `restricted` if there are no workloads that would fail.
115114

@@ -126,7 +125,7 @@ Additional diagnostics are required to confirm the full set of potential causes.
126125

127126
#### New SCC Annotation: `security.openshift.io/ValidatedSCCSubjectType`
128127

129-
The annotation `openshift.io/scc` currently indicates which SCC admitted a workload, but it does not distinguish **how** the SCC was grantedwhether 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 grantedwhether through a user or a Pod’s ServiceAccount.
130129
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.
131130
Because the PSA label syncer does not track user-based SCCs itself, it cannot fully assess labeling under those circumstances.
132131

@@ -177,8 +176,8 @@ import (
177176
// in the cluster. Unlike PSATargetMode, which reflects the user’s desired or “target”
178177
// setting, PSAEnforcementMode describes the effective mode currently active.
179178
//
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.
182181
type PSAEnforcementMode string
183182

184183
const (
@@ -213,7 +212,7 @@ const (
213212

214213
// TargetModeConditional indicates that the user is willing to let the cluster
215214
// 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.
217216
// This allows a gradual move towards label and global config enforcement without
218217
// immediately breaking workloads that are not yet compliant.
219218
TargetModeConditional PSATargetMode = "Conditional"
@@ -256,13 +255,17 @@ type PSAEnforcementConfigSpec struct {
256255
// PSAEnforcementConfigStatus defines the observed state of Pod Security
257256
// Admission enforcement.
258257
type PSAEnforcementConfigStatus struct {
258+
// enforcementMode indicates the effective Pod Security Admission enforcement
259+
// mode in the cluster. Unlike spec.targetMode, which expresses the desired mode,
260+
// enforcementMode reflects the actual state after considering any existing
261+
// violations or user overrides.
259262
EnforcementMode PSAEnforcementMode `json:"enforcmentMode"`
260263

261264
// violatingNamespaces is a list of namespaces that can initially block the
262265
// cluster from fully enforcing a "Restricted" mode. Administrators should
263266
// review each listed Namespace to fix any issues to enable strict enforcement.
264267
//
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,
266269
// it remains in "Restricted" until the user explicitly switches to
267270
// "spec.mode = Privileged".
268271
//
@@ -328,7 +331,7 @@ Below is a table illustrating the expected behavior when the `FeatureGate` `Open
328331

329332
A cluster that uses `spec.targetMode = Conditional` can revert to `Privileged` only if the user explicitly sets `spec.targetMode = Privileged`.
330333
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.
332335

333336
`status.violatingNamespaces` lists the Namespaces that would fail if `status.enforcementMode` were `LabelEnforcement` or `FullEnforcement`.
334337
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
337340
### Implementation Details
338341

339342
- 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`.
342352

343353
#### PodSecurity Configuration
344354

@@ -349,7 +359,7 @@ It must watch both the `status.enforcementMode` and the `FeatureGate` to make de
349359

350360
The PSA label syncer will watch the `status.enforcementMode` and the `OpenShiftPodSecurityAdmission` feature gate.
351361
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.
353363

354364
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`.
355365
Otherwise, the cluster will be unable to revert to its previous state.

0 commit comments

Comments
 (0)