Este contenido no está disponible en el idioma seleccionado.
Chapter 2. Using pods in a privileged security context
The default configuration of OpenShift Pipelines 1.3.x and later versions does not allow you to run pods with privileged security context, if the pods result from pipeline run or task run. For such pods, the default service account is pipeline, and the security context constraint (SCC) associated with the pipeline service account is pipelines-scc. The pipelines-scc SCC is similar to the anyuid SCC, but with minor differences as defined in the YAML file for the SCC of pipelines:
Example pipelines-scc.yaml snippet
In addition, the Buildah cluster task, shipped as part of the OpenShift Pipelines, uses vfs as the default storage driver.
2.1. Running pipeline run and task run pods with privileged security context Copiar enlaceEnlace copiado en el portapapeles!
Procedure
To run a pod (resulting from pipeline run or task run) with the privileged security context, do the following modifications:
Configure the associated user account or service account to have an explicit SCC. You can perform the configuration using any of the following methods:
Run the following command:
oc adm policy add-scc-to-user <scc-name> -z <service-account-name>
$ oc adm policy add-scc-to-user <scc-name> -z <service-account-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, modify the YAML files for
RoleBinding, andRoleorClusterRole:Example
RoleBindingobjectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example
ClusterRoleobjectCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Substitute with an appropriate cluster role based on the role binding you use.
NoteAs a best practice, create a copy of the default YAML files and make changes in the duplicate file.
-
If you do not use the
vfsstorage driver, configure the service account associated with the task run or the pipeline run to have a privileged SCC, and set the security context asprivileged: true.
2.2. Running pipeline run and task run by using a custom SCC and a custom service account Copiar enlaceEnlace copiado en el portapapeles!
When using the pipelines-scc security context constraint (SCC) associated with the default pipelines service account, the pipeline run and task run pods may face timeouts. This happens because in the default pipelines-scc SCC, the fsGroup.type parameter is set to MustRunAs.
For more information about pod timeouts, see BZ#1995779.
To avoid pod timeouts, you can create a custom SCC with the fsGroup.type parameter set to RunAsAny, and associate it with a custom service account.
As a best practice, use a custom SCC and a custom service account for pipeline runs and task runs. This approach allows greater flexibility and does not break the runs when the defaults are modified during an upgrade.
Procedure
Define a custom SCC with the
fsGroup.typeparameter set toRunAsAny:Example: Custom SCC
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the custom SCC:
Example: Create the
my-sccSCCoc create -f my-scc.yaml
$ oc create -f my-scc.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a custom service account:
Example: Create a
fsgroup-runasanyservice accountoc create serviceaccount fsgroup-runasany
$ oc create serviceaccount fsgroup-runasanyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Associate the custom SCC with the custom service account:
Example: Associate the
my-sccSCC with thefsgroup-runasanyservice accountoc adm policy add-scc-to-user my-scc -z fsgroup-runasany
$ oc adm policy add-scc-to-user my-scc -z fsgroup-runasanyCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you want to use the custom service account for privileged tasks, you can associate the
privilegedSCC with the custom service account by running the following command:Example: Associate the
privilegedSCC with thefsgroup-runasanyservice accountoc adm policy add-scc-to-user privileged -z fsgroup-runasany
$ oc adm policy add-scc-to-user privileged -z fsgroup-runasanyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the custom service account in the pipeline run and task run:
Example: Pipeline run YAML with
fsgroup-runasanycustom service accountCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example: Task run YAML with
fsgroup-runasanycustom service accountCopy to Clipboard Copied! Toggle word wrap Toggle overflow