Questo contenuto non è disponibile nella lingua selezionata.
Chapter 16. Understanding and managing pod security admission
Pod security admission is an implementation of the Kubernetes pod security standards. Use pod security admission to restrict the behavior of pods.
16.1. Security context constraint synchronization with pod security standards Copia collegamentoCollegamento copiato negli appunti!
OpenShift Container Platform includes Kubernetes pod security admission. Globally, the
privileged
restricted
In addition to the global pod security admission control configuration, a controller exists that applies pod security admission control
warn
audit
Namespaces that are defined as part of the cluster payload have pod security admission synchronization disabled permanently. You can enable pod security admission synchronization on other namespaces as necessary.
The controller examines
ServiceAccount
warn
audit
Namespace labeling is based on consideration of namespace-local service account privileges.
Applying pods directly might use the SCC privileges of the user who runs the pod. However, user privileges are not considered during automatic labeling.
16.2. Controlling pod security admission synchronization Copia collegamentoCollegamento copiato negli appunti!
You can enable or disable automatic pod security admission synchronization for most namespaces.
Namespaces that are defined as part of the cluster payload have pod security admission synchronization disabled permanently. These namespaces include:
-
default -
kube-node-lease -
kube-system -
kube-public -
openshift -
All system-created namespaces that are prefixed with , except for
openshift-openshift-operators
By default, all namespaces that have an
openshift-
openshift-*
openshift-*
openshift-operators
Procedure
For each namespace that you want to configure, set a value for the
label:security.openshift.io/scc.podSecurityLabelSyncTo disable pod security admission label sychronization in a namespace, set the value of the
label tosecurity.openshift.io/scc.podSecurityLabelSync.falseRun the following command:
$ oc label namespace <namespace> security.openshift.io/scc.podSecurityLabelSync=falseTo enable pod security admission label sychronization in a namespace, set the value of the
label tosecurity.openshift.io/scc.podSecurityLabelSync.trueRun the following command:
$ oc label namespace <namespace> security.openshift.io/scc.podSecurityLabelSync=true
16.3. About pod security admission alerts Copia collegamentoCollegamento copiato negli appunti!
A
PodSecurityViolation
View the Kubernetes API server audit logs to investigate alerts that were triggered. As an example, a workload is likely to fail admission if global enforcement is set to the
restricted
For assistance in identifying pod security admission violation audit events, see Audit annotations in the Kubernetes documentation.
16.3.1. Identifying pod security violations Copia collegamentoCollegamento copiato negli appunti!
The
PodSecurityViolation
must-gather
pod-security.kubernetes.io/audit-violations
Prerequisites
-
You have installed .
jq -
You have access to the cluster as a user with the role.
cluster-admin
Procedure
To gather the audit logs, enter the following command:
$ oc adm must-gather -- /usr/bin/gather_audit_logsTo output the affected workload details, enter the following command:
$ zgrep -h pod-security.kubernetes.io/audit-violations must-gather.local.<archive_id>/quay*/audit_logs/kube-apiserver/*log.gz \ | jq -r 'select((.annotations["pod-security.kubernetes.io/audit-violations"] != null) and (.objectRef.resource=="pods")) | .objectRef.namespace + " " + .objectRef.name + " " + .objectRef.resource' \ | sort | uniq -cReplace
with the actual directory name.must-gather.local.<archive_id>Example output
15 ci namespace-ttl-controller deployments 1 ci-op-k5whzrsh rpm-repo-546f98d8b replicasets 1 ci-op-k5whzrsh rpm-repo deployments