|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * storage/generic-ephemeral-vols.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="generic-ephemeral-vols-scc-bug_{context}"] |
| 7 | += Creating a custom SCC to allow use of generic ephemeral volumes |
| 8 | + |
| 9 | +The default security context constraint (SCC) might cause a cluster deployment using generic ephemeral volumes to remain in the pending state. |
| 10 | + |
| 11 | +To work around this issue, you can create a custom SCC. |
| 12 | + |
| 13 | +.Procedure |
| 14 | + |
| 15 | +. Copy the restricted SCC by running the following command: |
| 16 | ++ |
| 17 | +[source, terminal] |
| 18 | +---- |
| 19 | +$ oc get scc restricted -o yaml > ephemeral_restricted_scc.yaml |
| 20 | +---- |
| 21 | + |
| 22 | +. Modify the SCC YAML file as follows: |
| 23 | ++ |
| 24 | +* Remove the generated metadata. |
| 25 | +* Change the name of the SCC. |
| 26 | +* Under the `volumes` section, add an `ephemeral` value. |
| 27 | ++ |
| 28 | +.ephemera_restricted_scc.yaml |
| 29 | +[source, yaml] |
| 30 | +---- |
| 31 | +allowHostDirVolumePlugin: false |
| 32 | +allowHostIPC: false |
| 33 | +allowHostNetwork: false |
| 34 | +allowHostPID: false |
| 35 | +allowHostPorts: false |
| 36 | +allowPrivilegeEscalation: true |
| 37 | +allowPrivilegedContainer: false |
| 38 | +allowedCapabilities: null |
| 39 | +apiVersion: security.openshift.io/v1 |
| 40 | +defaultAddCapabilities: null |
| 41 | +fsGroup: |
| 42 | + type: MustRunAs |
| 43 | +groups: [] |
| 44 | +kind: SecurityContextConstraints |
| 45 | +metadata: |
| 46 | + name: ephemeral-restricted <1> |
| 47 | +priority: null |
| 48 | +readOnlyRootFilesystem: false |
| 49 | +requiredDropCapabilities: |
| 50 | +- KILL |
| 51 | +- MKNOD |
| 52 | +- SETUID |
| 53 | +- SETGID |
| 54 | +runAsUser: |
| 55 | + type: MustRunAsRange |
| 56 | +seLinuxContext: |
| 57 | + type: MustRunAs |
| 58 | +supplementalGroups: |
| 59 | + type: RunAsAny |
| 60 | +users: [] |
| 61 | +volumes: |
| 62 | +- configMap |
| 63 | +- downwardAPI |
| 64 | +- emptyDir |
| 65 | +- persistentVolumeClaim |
| 66 | +- projected |
| 67 | +- secret |
| 68 | +- ephemeral <2> |
| 69 | +---- |
| 70 | +<1> New SCC name. |
| 71 | +<2> Specifies ephemeral volumes. |
| 72 | + |
| 73 | +. Create the new SCC YAML file using the following command: |
| 74 | ++ |
| 75 | +[source, terminal] |
| 76 | +---- |
| 77 | +$ oc create -f ephemeral_restricted_scc.yaml |
| 78 | +---- |
| 79 | + |
| 80 | +.Next steps |
| 81 | + |
| 82 | +This new SCC can be either assigned to individual projects or groups. For more information, see _Managing security context constraints_. |
| 83 | + |
| 84 | +Also, the newly created SCC can be assigned to a specific namespace, so that only the pods that are in that namespace can have access to this new SCC. This allows users in that namespace to create pods that use generic ephemeral volumes. |
| 85 | + |
| 86 | +To assign the new SCC to a specific namespace, use the following command: |
| 87 | + |
| 88 | +[source, terminal] |
| 89 | +---- |
| 90 | +$ oc adm policy add-scc-to-group <scc_name> \ system:serviceaccounts:<serviceaccount_namespace> |
| 91 | +---- |
0 commit comments