Skip to content

Commit 2afb4a3

Browse files
OSDOCS-4047 and OSDOCS-3861: Operator workloads and PSA compliance
1 parent da1ac3a commit 2afb4a3

5 files changed

+161
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,8 @@ Topics:
17691769
File: osdk-generating-csvs
17701770
- Name: Working with bundle images
17711771
File: osdk-working-bundle-images
1772+
- Name: Complying with pod security admission
1773+
File: osdk-complying-with-psa
17721774
- Name: Validating Operators using the scorecard
17731775
File: osdk-scorecard
17741776
- Name: Validating Operator bundles
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * operators/operator_sdk/osdk-complying-with-psa.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="osdk-ensuring-operator-workloads-run-restricted-psa_{context}"]
7+
= Ensuring Operator workloads run in namespaces set to the restricted pod security level
8+
9+
To ensure your Operator project can run on a wide variety of deployments and environments, configure the Operator's workloads to run in namespaces set to the `restricted` pod security level.
10+
11+
[WARNING]
12+
====
13+
You must leave the `runAsUser` field empty. If your image requires a specific user, it cannot be run under restricted security context constraints (SCC) and restricted pod security enforcement.
14+
====
15+
16+
.Procedure
17+
18+
* To configure Operator workloads to run in namespaces set to the `restricted` pod security level, edit your Operator's namespace definition similar to the following examples:
19+
+
20+
[IMPORTANT]
21+
====
22+
It is recommended that you set the seccomp profile in your Operator's namespace definition. However, setting the seccomp profile is not supported in {product-title} 4.10.
23+
====
24+
25+
** For Operator projects that must run in only {product-title} 4.11 and later, edit your Operator's namespace definition similar to the following example:
26+
+
27+
.Example `config/manager/manager.yaml` file
28+
[source,yaml]
29+
----
30+
...
31+
spec:
32+
securityContext:
33+
seccompProfile:
34+
type: RuntimeDefault <1>
35+
runAsNonRoot: true
36+
containers:
37+
- name: <operator_workload_container>
38+
securityContext:
39+
allowPrivilegeEscalation: false
40+
capabilities:
41+
drop:
42+
- ALL
43+
...
44+
----
45+
<1> By setting the seccomp profile type to `RuntimeDefault`, the SCC defaults to the pod security profile of the namespace.
46+
47+
** For Operator projects that must also run in {product-title} 4.10, edit your Operator's namespace definition similar to the following example:
48+
+
49+
.Example `config/manager/manager.yaml` file
50+
[source,yaml]
51+
----
52+
...
53+
spec:
54+
securityContext: <1>
55+
runAsNonRoot: true
56+
containers:
57+
- name: <operator_workload_container>
58+
securityContext:
59+
allowPrivilegeEscalation: false
60+
capabilities:
61+
drop:
62+
- ALL
63+
...
64+
----
65+
<1> Leaving the seccomp profile type unset ensures your Operator project can run in {product-title} 4.10.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * operators/operator_sdk/osdk-complying-with-psa.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="osdk-managing-psa-for-operators-with-escalated-permissions.adoc_{context}"]
7+
= Managing pod security admission for Operator workloads that require escalated permissions
8+
9+
If your Operator project requires escalated permissions to run, you must edit your Operator's cluster service version (CSV).
10+
11+
.Procedure
12+
13+
. Set the security context configuration to the required permission level in your Operator's CSV, similar to the following example:
14+
+
15+
.Example `<operator_name>.clusterserviceversion.yaml` file with network administrator privileges
16+
[source,yaml]
17+
----
18+
...
19+
containers:
20+
- name: my-container
21+
securityContext:
22+
allowPrivilegeEscalation: false
23+
capabilities:
24+
add:
25+
- "NET_ADMIN"
26+
...
27+
----
28+
29+
. Set the service account privileges that allow your Operator's workloads to use the required security context constraints (SCC), similar to the following example:
30+
+
31+
.Example `<operator_name>.clusterserviceversion.yaml` file
32+
[source,yaml]
33+
----
34+
...
35+
install:
36+
spec:
37+
clusterPermissions:
38+
- rules:
39+
- apiGroups:
40+
- security.openshift.io
41+
resourceNames:
42+
- privileged
43+
resources:
44+
- securitycontextconstraints
45+
verbs:
46+
- use
47+
serviceAccountName: default
48+
...
49+
----
50+
51+
. Edit your Operator's CSV description to explain why your Operator project requires escalated permissions similar to the following example:
52+
+
53+
.Example `<operator_name>.clusterserviceversion.yaml` file
54+
[source,yaml]
55+
----
56+
...
57+
spec:
58+
apiservicedefinitions:{}
59+
...
60+
description: The <operator_name> requires a privileged pod security admission label set on the Operator's namespace. The Operator's agents require escalated permissions to restart the node if the node needs remediation.
61+
----

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Module included in the following assemblies:
22
//
33
// * authentication/understanding-and-managing-pod-security-admission.adoc
4+
// * operators/operator_sdk/osdk-complying-with-psa.adoc
45

56
:_content-type: CONCEPT
67
[id="security-context-constraints-psa-synchronization_{context}"]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
:_content-type: ASSEMBLY
2+
[id="osdk-complying-with-psa"]
3+
= Complying with pod security admission
4+
include::_attributes/common-attributes.adoc[]
5+
:context: osdk-complying-with-psa.adoc
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]. link:https://kubernetes.io/docs/concepts/security/pod-security-admission/[Pod security admission] restricts the behavior of pods. 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.
10+
11+
If your Operator project does not require escalated permissions to run, you can ensure your workloads run in namespaces set to the `restricted` pod security level. If your Operator project requires escalated permissions to run, you must set the following security context configurations:
12+
13+
* The allowed pod security admission level for the Operator's namespace
14+
* The allowed security context constraints (SCC) for the workload's service account
15+
16+
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].
17+
18+
include::modules/security-context-constraints-psa-synchronization.adoc[leveloffset=+1]
19+
include::modules/osdk-ensuring-operator-workloads-run-restricted-psa.adoc[leveloffset=+1]
20+
21+
[role="_additional-resources"]
22+
.Additional resources
23+
24+
* xref:../../authentication/managing-security-context-constraints.adoc#managing-security-context-constraints[Managing security context constraints]
25+
26+
include::modules/osdk-managing-psa-for-operators-with-escalated-permissions.adoc[leveloffset=+1]
27+
28+
[id="osdk-complying-with-psa-additional-resources"]
29+
[role="_additional-resources"]
30+
== Additional resources
31+
32+
* xref:../../authentication/understanding-and-managing-pod-security-admission.adoc#understanding-and-managing-pod-security-admission[Understanding and managing pod security admission]

0 commit comments

Comments
 (0)