Skip to content

Commit d1eb137

Browse files
s-urbaniakbergerhoffer
authored andcommitted
OSDOCS-3536: Docs for setting a required SCC
1 parent 1d98476 commit d1eb137

File tree

2 files changed

+75
-3
lines changed

2 files changed

+75
-3
lines changed

authentication/managing-security-context-constraints.adoc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Default SCCs are created during installation and when you install some Operators
1212

1313
[IMPORTANT]
1414
====
15-
Do not modify the default SCCs. Customizing the default SCCs can lead to issues when some of the platform pods deploy or
15+
Do not modify the default SCCs. Customizing the default SCCs can lead to issues when some of the platform pods deploy or
1616
ifndef::openshift-rosa[]
17-
{product-title}
17+
{product-title}
1818
endif::[]
1919
ifdef::openshift-rosa[]
20-
ROSA
20+
ROSA
2121
endif::openshift-rosa[]
2222
is upgraded. Additionally, the default SCC values are reset to the defaults during some cluster upgrades, which discards all customizations to those SCCs.
2323
ifdef::openshift-origin,openshift-enterprise,openshift-webscale,openshift-dedicated,openshift-rosa[]
@@ -37,6 +37,9 @@ include::modules/security-context-constraints-about.adoc[leveloffset=+1]
3737
include::modules/security-context-constraints-pre-allocated-values.adoc[leveloffset=+1]
3838
include::modules/security-context-constraints-example.adoc[leveloffset=+1]
3939
include::modules/security-context-constraints-creating.adoc[leveloffset=+1]
40+
41+
// Configuring a workload to require a specific SCC
42+
include::modules/security-context-constraints-requiring.adoc[leveloffset=+1]
4043
include::modules/security-context-constraints-rbac.adoc[leveloffset=+1]
4144
include::modules/security-context-constraints-command-reference.adoc[leveloffset=+1]
4245

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * authentication/managing-security-context-constraints.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="security-context-constraints-requiring_{context}"]
7+
= Configuring a workload to require a specific SCC
8+
9+
You can configure a workload to require a certain security context constraint (SCC). This is useful in scenarios where you want to pin a specific SCC to the workload or if you want to prevent your required SCC from being preempted by another SCC in the cluster.
10+
11+
To require a specific SCC, set the `openshift.io/required-scc` annotation on your workload. You can set this annotation on any resource that can set a pod manifest template, such as a deployment or daemon set.
12+
13+
The SCC must exist in the cluster and must be applicable to the workload, otherwise pod admission fails. An SCC is considered applicable to the workload if the user creating the pod or the pod's service account has `use` permissions for the SCC in the pod's namespace.
14+
15+
[WARNING]
16+
====
17+
Do not change the `openshift.io/required-scc` annotation in the live pod's manifest, because doing so causes the pod admission to fail. To change the required SCC, update the annotation in the underlying pod template, which causes the pod to be deleted and re-created.
18+
====
19+
20+
.Prerequisites
21+
22+
* The SCC must exist in the cluster.
23+
24+
.Procedure
25+
26+
. Create a YAML file for the deployment and specify a required SCC by setting the `openshift.io/required-scc` annotation:
27+
+
28+
.Example `deployment.yaml`
29+
[source,yaml]
30+
----
31+
apiVersion: config.openshift.io/v1
32+
kind: Deployment
33+
apiVersion: apps/v1
34+
spec:
35+
# ...
36+
template:
37+
metadata:
38+
annotations:
39+
openshift.io/required-scc: "my-scc" <1>
40+
# ...
41+
----
42+
<1> Specify the name of the SCC to require.
43+
44+
. Create the resource by running the following command:
45+
+
46+
[source,terminal]
47+
----
48+
$ oc create -f deployment.yaml
49+
----
50+
51+
.Verification
52+
53+
* Verify that the deployment used the specified SCC:
54+
55+
.. View the value of the pod's `openshift.io/scc` annotation by running the following command:
56+
+
57+
[source,terminal]
58+
----
59+
$ oc get pod <pod_name> -o jsonpath='{.metadata.annotations.openshift\.io\/scc}{"\n"}' <1>
60+
----
61+
<1> Replace `<pod_name>` with the name of your deployment pod.
62+
63+
.. Examine the output and confirm that the displayed SCC matches the SCC that you defined in the deployment:
64+
+
65+
.Example output
66+
[source,terminal]
67+
----
68+
my-scc
69+
----

0 commit comments

Comments
 (0)