Questo contenuto non è disponibile nella lingua selezionata.
Chapter 7. Security policies
Virtual machine (VM) workloads run as unprivileged pods. So that VMs can use OpenShift Virtualization features, some pods are granted custom security policies that are not available to other pod owners:
-
An extended SELinux policy applies to
container_tpods.virt-launcher -
Security context constraints (SCCs) are defined for the service account.
kubevirt-controller
7.1. About workload security Copia collegamentoCollegamento copiato negli appunti!
By default, virtual machine (VM) workloads do not run with root privileges in OpenShift Virtualization.
For each VM, a
virt-launcher
libvirt
libvirt
There are no supported OpenShift Virtualization features that require root privileges. If a feature requires root, it might not be supported for use with OpenShift Virtualization.
7.2. Extended SELinux policies for virt-launcher pods Copia collegamentoCollegamento copiato negli appunti!
The
container_t
virt-launcher
The following policy is required for network multi-queue, which enables network performance to scale as the number of available vCPUs increases:
-
allow process self (tun_socket (relabelfrom relabelto attach_queue))
-
The following policy allows
to read files under thevirt-launcherdirectory, including/procand/proc/cpuinfo:/proc/uptime-
allow process proc_type (file (getattr open read))
-
The following policy allows
to relay network-related debug messages.libvirtdallow process self (netlink_audit_socket (nlmsg_relay))NoteWithout this policy, any attempt to relay network debug messages is blocked. This might fill the node’s audit logs with SELinux denials.
The following policies allow
to accesslibvirtd, which is required to support huge pages:hugetblfs-
allow process hugetlbfs_t (dir (add_name create write remove_name rmdir setattr)) -
allow process hugetlbfs_t (file (create unlink))
-
The following policies allow
to mount filesystems and access NFS:virtiofs-
allow process nfs_t (dir (mounton)) -
allow process proc_t (dir (mounton)) -
allow process proc_t (filesystem (mount unmount))
-
7.3. Additional OpenShift Container Platform security context constraints and Linux capabilities for the kubevirt-controller service account Copia collegamentoCollegamento copiato negli appunti!
Security context constraints (SCCs) control permissions for pods. These permissions include actions that a pod, a collection of containers, can perform and what resources it can access. You can use SCCs to define a set of conditions that a pod must run with to be accepted into the system.
The
virt-controller
virt-launcher
kubevirt-controller
The
kubevirt-controller
virt-launcher
The
kubevirt-controller
-
scc.AllowHostDirVolumePlugin = true
This allows virtual machines to use the hostpath volume plugin. -
scc.AllowPrivilegedContainer = false
This ensures the virt-launcher pod is not run as a privileged container. scc.AllowedCapabilities = []corev1.Capability{"SYS_NICE", "NET_BIND_SERVICE", "SYS_PTRACE"}
-
allows setting the CPU affinity.
SYS_NICE -
allows DHCP and Slirp operations.
NET_BIND_SERVICE -
enables certain versions of
SYS_PTRACEto find the process ID (PID) oflibvirt, a software Trusted Platform Module (TPM) emulator.swtpm
-
7.3.1. Viewing the SCC and RBAC definitions for the kubevirt-controller Copia collegamentoCollegamento copiato negli appunti!
You can view the
SecurityContextConstraints
kubevirt-controller
oc
$ oc get scc kubevirt-controller -o yaml
You can view the RBAC definition for the
kubevirt-controller
oc
$ oc get clusterrole kubevirt-controller -o yaml