このコンテンツは選択した言語では利用できません。
Chapter 5. Postinstallation configuration
5.1. Run automated postinstallation configuration リンクのコピーリンクがクリップボードにコピーされました!
The virt-platform-autopilot controller replaces manual postinstallation configuration by automatically applying opinionated defaults to the virtualization platform and installed optional components. You can customize or opt out of any managed configuration.
5.1.1. How automated postinstallation configuration works リンクのコピーリンクがクリップボードにコピーされました!
After you install OpenShift Virtualization, the virt-platform-autopilot controller continuously reconciles managed resources to keep the expected state and correct configuration drift. It also configures optional components such as the Kube Descheduler Operator and the Cluster Observability Operator if they are installed.
The virt-platform-autopilot controller manages the following configurations:
- Load-aware descheduler
- Configures the Kube Descheduler Operator to balance virtual machine (VM) workloads across nodes based on CPU and memory use. Requires the Kube Descheduler Operator to be installed.
- Observability enhancements
- Enhances observability with additional Prometheus alerting rules and advanced Perses dashboards in the OpenShift Container Platform web console.
- Swap enablement
- Enables OpenShift Container Platform worker nodes to safely use swap for virtualization workloads. Swap requires pre-provisioned, dedicated storage to be available.
5.1.1.1. Soft dependency model リンクのコピーリンクがクリップボードにコピーされました!
The virt-platform-autopilot controller does not install optional components. It configures components that are already installed on the cluster. If an optional component is not installed, the virt-platform-autopilot controller skips that configuration and continues without error.
When you install an optional component later, the virt-platform-autopilot controller detects it on the next reconciliation cycle and applies the relevant configuration automatically.
5.1.1.2. Reconciliation and anti-thrashing behavior リンクのコピーリンクがクリップボードにコピーされました!
The virt-platform-autopilot controller continuously reconciles managed resources to keep the expected state. If an external process changes a managed resource, the virt-platform-autopilot controller detects the drift and restores the expected state.
To prevent thrashing, the virt-platform-autopilot controller monitors the rate of changes to managed resources. If the virt-platform-autopilot controller detects rapid or repeated changes, it pauses reconciliation for the affected resources. This prevents a loop where the virt-platform-autopilot controller and another controller repeatedly overwrite each other’s changes. You can monitor paused resources by using the kubevirt_autopilot_paused_resources metric.
5.1.2. Customize or opt-out of managed configurations リンクのコピーリンクがクリップボードにコピーされました!
The virt-platform-autopilot controller applies opinionated defaults, but you can override managed configurations to suit your environment.
z
- Stop reconciliation of a resource
- Mark a resource as unmanaged so that the controller does not reconcile it after it is created. You take full ownership of that resource’s configuration.
You can combine these approaches across different resources in the same cluster.
5.1.2.1. Exclude a resource from being managed by the virt-platform-autopilot controller リンクのコピーリンクがクリップボードにコピーされました!
Disabled resources are not created or reconciled automatically by the virt-platform-autopilot controller. Prevent the controller from creating or reconciling a resource by disabling it in the HyperConverged custom resource (CR).
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You have logged in to the cluster as a user with
cluster-adminprivileges. -
The
virt-platform-autopilotcontroller is enabled on the cluster.
Procedure
Edit the
HyperConvergedCR and add resources to theplatform.kubevirt.io/disabled-resourcesannotation:Example
HyperConvergedCR:apiVersion: hco.kubevirt.io/v1beta1 kind: HyperConverged metadata: annotations: platform.kubevirt.io/disabled-resources: | - kind: KubeDescheduler name: cluster - kind: MachineConfig name: 90-worker-swap-onlineApply your changes to the
HyperConvergedCR by running the following command:$ oc apply -f <filename>.yaml
5.1.2.2. Customize specific values in a managed resource リンクのコピーリンクがクリップボードにコピーされました!
Customize specific values in a managed resource by applying a JSON patch on top of the reconciled configuration to retain your custom settings.
Deleting an unmanaged resource causes any annotations on that resource to be lost. The virt-platform-autopilot controller then creates a new, opinionated version of the resource.
To prevent the virt-platform-autopilot controller from recreating deleted resources, you must disable the resource. You can disable resources by adding them to the platform.kubevirt.io/disabled-resources annotation in the HyperConverged custom resource (CR).
For more information, see "Exclude a resource from being managed by the virt-platform-autopilot controller".
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You have logged in to the cluster as a user with
cluster-adminprivileges. -
The
virt-platform-autopilotcontroller is enabled on the cluster. -
The
platform.kubevirt.io/mode=unmanagedandplatform.kubevirt.io/ignore-fieldsannotations must not be present on the resource.
Procedure
Add the
platform.kubevirt.io/patchannotation to a resource with a valid RFC 6902 JSON Patch operations array.For example, to prevent the
virt-platform-autopilotcontroller from overriding a custom descheduler profile configuration, run the following command:$ oc annotate kubedescheduler cluster \ 'platform.kubevirt.io/patch=[{"op":"replace","path":"/spec/profileCustomizations","value":{"devKnobs":{}}}]' \ -n openshift-kube-descheduler-operatorThe
virt-platform-autopilotcontroller continues to manage all other fields on the resource but skips the specified paths.ImportantJSON patches are blocked on sensitive resources, including
MachineConfigandKubeletConfigresources.Optional: To restore
virt-platform-autopilotcontroller management for all fields, remove theplatform.kubevirt.io/patchannotation.For example, to restore
virt-platform-autopilotcontroller management for all fields of the descheduler configuration, run the following command:$ oc annotate kubedescheduler cluster \ platform.kubevirt.io/patch- \ -n openshift-kube-descheduler-operator
5.1.2.3. Exclude specific fields from reconciliation in a managed resource リンクのコピーリンクがクリップボードにコピーされました!
Exclude specific fields from being managed by the virt-platform-autopilot controller so that it ignores them during reconciliation.
Deleting an unmanaged resource causes any annotations on that resource to be lost. The virt-platform-autopilot controller then creates a new, opinionated version of the resource.
To prevent the virt-platform-autopilot controller from recreating deleted resources, you must disable the resource. You can disable resources by adding them to the platform.kubevirt.io/disabled-resources annotation in the HyperConverged custom resource (CR).
For more information, see "Exclude a resource from being managed by the virt-platform-autopilot controller".
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You have logged in to the cluster as a user with
cluster-adminprivileges. -
The
virt-platform-autopilotcontroller is enabled on the cluster. -
The
platform.kubevirt.io/mode=unmanagedandplatform.kubevirt.io/patchannotations must not be present on the resource.
Procedure
Add the
platform.kubevirt.io/ignore-fieldsannotation with a comma-separated list of RFC 6901 JSON Pointer paths.For example, to prevent the
virt-platform-autopilotcontroller from overriding a systemd unit in a managedMachineConfigresource, run the following command:$ oc annotate machineconfig 90-worker-swap-online \ platform.kubevirt.io/ignore-fields='/spec/config/systemd/units/0/contents'Optional: To restore
virt-platform-autopilotcontroller management for all fields, remove theplatform.kubevirt.io/ignore-fieldsannotation.For example, to restore
virt-platform-autopilotcontroller management for all fields of the descheduler configuration, run the following command:$ oc annotate kubedescheduler cluster \ platform.kubevirt.io/ignore-fields- \ -n openshift-kube-descheduler-operator
5.1.2.4. Stop reconciliation of a managed resource リンクのコピーリンクがクリップボードにコピーされました!
Mark a resource as unmanaged so that the virt-platform-autopilot controller does not reconcile it after it is created. You take full ownership of that resource’s configuration.
Deleting an unmanaged resource causes any annotations on that resource to be lost. The virt-platform-autopilot controller then creates a new, opinionated version of the resource.
To prevent the virt-platform-autopilot controller from recreating deleted resources, you must disable the resource. You can disable resources by adding them to the platform.kubevirt.io/disabled-resources annotation in the HyperConverged custom resource (CR).
For more information, see "Exclude a resource from being managed by the virt-platform-autopilot controller".
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You have logged in to the cluster as a user with
cluster-adminprivileges. -
The
virt-platform-autopilotcontroller is enabled on the cluster. -
The
platform.kubevirt.io/ignore-fieldsandplatform.kubevirt.io/patchannotations must not be present on the resource.
Procedure
Set the
platform.kubevirt.io/modeannotation for the resource tounmanaged.For example, to stop the
virt-platform-autopilotcontroller from managing the descheduler configuration, run the following command:$ oc annotate kubedescheduler cluster \ platform.kubevirt.io/mode=unmanaged \ -n openshift-kube-descheduler-operatorOptional: To restore
virt-platform-autopilotcontroller management for a resource, remove theplatform.kubevirt.io/modeannotation.For example, to restore
virt-platform-autopilotcontroller management for the descheduler configuration, run the following command:$ oc annotate kubedescheduler cluster \ platform.kubevirt.io/mode- \ -n openshift-kube-descheduler-operator
5.2. Postinstallation configuration リンクのコピーリンクがクリップボードにコピーされました!
After you have installed OpenShift Virtualization, there are procedures that you can complete to ensure that your environment is properly set up. You can configure the components that are relevant for your environment.
- As a cluster administrator, you can run a self validation checkup to verify that the environment is fully functional and self-sustained before you deploy production workloads.
- The hostpath provisioner is a local storage provisioner designed for OpenShift Virtualization. If you want to configure local storage for virtual machines, you must enable the hostpath provisioner first.
- Node placement rules for OpenShift Virtualization Operators, workloads, and controllers.
Network configuration:
- Installing the Kubernetes NMState and SR-IOV Operators
- Configuring a Linux bridge network for external access to virtual machines (VMs)
- Configuring a dedicated secondary network for live migration
- Configuring an SR-IOV network
- Enabling the creation of load balancer services by using the OpenShift Container Platform web console
Storage configuration:
- Defining a default storage class for the Container Storage Interface (CSI)
- Configuring local storage by using the Hostpath Provisioner (HPP)
5.2.1. Self-service Technical Supportability Review リンクのコピーリンクがクリップボードにコピーされました!
You can use the self-service Technical Supportability Review (TSR) on the Red Hat Customer Portal to validate your cluster configuration against Red Hat common practices.
The must-gather tool collects diagnostic information about your cluster, including resource definitions, service logs, and configuration data. For more information, see "Gathering data about your cluster" in the OpenShift Container Platform documentation.
The self-service TSR uses AI to evaluate your cluster’s must-gather data and provides a prioritized executive summary of recommendations. This serves as a starting point to help you identify and resolve potential issues before they impact your environment.
The TSR performs hundreds of checks across the OpenShift Container Platform platform, including OpenShift Virtualization. Coverage is continually expanding.
5.2.1.1. When to use the self-service TSR tool リンクのコピーリンクがクリップボードにコピーされました!
Integrating the self-service TSR into your regular operational workflow can be helpful in the following scenarios:
- Routine benchmarking
- Use the TSR quarterly to benchmark cluster health and plan for routine maintenance activities.
- Pre-flight checks
- Validate your cluster configuration before major structural changes, including upgrades, migrations, and expansions.
- Critical event preparation
- Confirm cluster stability ahead of high-traffic business events, such as seasonal peaks, or operational milestones, such as year-end shutdowns, business continuity drills, and compliance audits.
5.2.1.2. How to access the TSR リンクのコピーリンクがクリップボードにコピーされました!
To run a self-service review, upload your cluster’s must-gather data to the Analyze tab in the Support section of the Red Hat Customer Portal. For a direct link, see "Technical Supportability Review with AI tool" in the Additional resources section. The Analyze feature generates a prioritized executive summary that identifies your cluster’s top risks and recommends corrective actions. Review the recommendations and implement the suggested corrective actions to address the identified risks.
The self-service TSR provides a solid baseline for cluster health. If you need additional guidance or a more comprehensive review, contact your Red Hat account team to arrange an assisted review through a Technical Account Manager (TAM) or Red Hat consultant. An assisted review includes human analysis, deeper coverage, and access to checks that are updated more frequently than the self-service version.
5.3. Specifying nodes for OpenShift Virtualization components リンクのコピーリンクがクリップボードにコピーされました!
You can configure node placement rules to specify where OpenShift Virtualization Operators, workloads, and controllers are deployed. Custom placement rules allow you to isolate virtual machine (VM) traffic or dedicate specialized compute resources to critical workloads.
You can configure node placement rules for some components after installing OpenShift Virtualization, but virtual machines cannot be present if you want to configure node placement rules for workloads.
5.3.1. About node placement rules for OpenShift Virtualization components リンクのコピーリンクがクリップボードにコピーされました!
You can use node placement rules to deploy virtual machines only on nodes intended for virtualization workloads, to deploy Operators only on infrastructure nodes, or to maintain separation between workloads.
Depending on the object, you can use one or more of the following rule types:
nodeSelector- Allows pods to be scheduled on nodes that are labeled with the key-value pair or pairs that you specify in this field. The node must have labels that exactly match all listed pairs.
affinity- Enables you to use more expressive syntax to set rules that match nodes with pods. Affinity also allows for more nuance in how the rules are applied. For example, you can specify that a rule is a preference, not a requirement. If a rule is a preference, pods are still scheduled when the rule is not satisfied.
tolerations- Allows pods to be scheduled on nodes that have matching taints. If a taint is applied to a node, that node only accepts pods that tolerate the taint.
If you are running an IBM Z or IBM LinuxONE (s390x) cluster with mixed hypervisors, refer to the following table for the supported nodes to run the virtual machines.
| Node architecture | Hypervisor | VM deployment | Node selection | VM architecture |
|---|---|---|---|---|
| s390x | LPAR | Supported | set node selector for LPAR node | s390x |
| s390x | z/VM | Unsupported | set anti-affinity for z/VM node | Not applicable |
| s390x | KVM | Unsupported | set anti-affinity for KVM node | Not applicable |
The scheduler does not select LPAR over z/VM or KVM nodes on s390x by default. To have a supported s390x virtual machine, you must set at least one s390x LPAR node as a schedulable compute node and you must set the node selector before deploying the virtual machine.
5.3.2. Apply node placement rules リンクのコピーリンクがクリップボードにコピーされました!
You can apply node placement rules to ensure that virtualization components run on the most suitable nodes for your workload requirements. You can apply node placement rules by editing OpenShift Virtualization objects.
Prerequisites
-
You have installed the OpenShift CLI (
oc). - You are logged in with cluster administrator permissions.
Procedure
Edit the object in your default editor by running the following command:
$ oc edit <resource_type> <resource_name> -n openshift-cnv- Save the file to apply the changes.
5.3.3. Node placement rule examples リンクのコピーリンクがクリップボードにコピーされました!
Examples of node placement rules for different objects that determine where OpenShift Virtualization components are deployed.
5.3.3.1. Subscription object node placement rule examples リンクのコピーリンクがクリップボードにコピーされました!
To specify the nodes where OLM deploys the OpenShift Virtualization Operators, edit the Subscription object during OpenShift Virtualization installation.
-
You cannot configure node placement rules for the
Subscriptionobject by using the web console. -
The
Subscriptionobject does not support theaffinitynode placement rule.
Example Subscription object with nodeSelector rule:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: hco-operatorhub
namespace: openshift-cnv
spec:
source: redhat-operators
sourceNamespace: openshift-marketplace
name: kubevirt-hyperconverged
startingCSV: kubevirt-hyperconverged-operator.v5.0.0
channel: "stable"
config:
nodeSelector:
example.io/example-infra-key: example-infra-value
OLM deploys the OpenShift Virtualization Operators on nodes labeled example.io/example-infra-key = example-infra-value.
The following pods are affected by the Subscription object node placement rules. These pods are created when the OpenShift Virtualization Operator is first installed, even without an HyperConverged custom resource (CR):
-
aaq-operator -
cdi-operator -
cluster-network-addons-operator -
hco-operator -
hco-webhook -
hostpath-provisioner-operator -
hyperconverged-cluster-cli-download -
kubevirt-migration-operator -
ssp-operator -
virt-operator
Example Subscription object with tolerations rule:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: hco-operatorhub
namespace: openshift-cnv
spec:
source: redhat-operators
sourceNamespace: openshift-marketplace
name: kubevirt-hyperconverged
startingCSV: kubevirt-hyperconverged-operator.v5.0.0
channel: "stable"
config:
tolerations:
- key: "key"
operator: "Equal"
value: "virtualization"
effect: "NoSchedule"
OLM deploys OpenShift Virtualization Operators on nodes labeled key = virtualization:NoSchedule taint. Only pods with the matching tolerations are scheduled on these nodes.
5.3.3.2. HyperConverged object node placement rule example リンクのコピーリンクがクリップボードにコピーされました!
To specify the nodes where OpenShift Virtualization deploys its components, you can edit the nodePlacement object in the HyperConverged custom resource (CR) file that you create during OpenShift Virtualization installation.
Example HyperConverged object with nodeSelector rule:
apiVersion: hco.kubevirt.io/v1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
namespace: openshift-cnv
spec:
deployment:
nodePlacements:
infra:
nodeSelector:
example.io/example-infra-key: example-infra-value
workload:
nodeSelector:
example.io/example-workloads-key: example-workloads-value
-
Infrastructure resources are placed on nodes labeled
example.io/example-infra-key = example-infra-value. -
Workloads are placed on nodes labeled
example.io/example-workloads-key = example-workloads-value.
Example HyperConverged object with affinity rule:
apiVersion: hco.kubevirt.io/v1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
namespace: openshift-cnv
spec:
deployment:
nodePlacements:
infra:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: example.io/example-infra-key
operator: In
values:
- example-infra-value
workload:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: example.io/example-workloads-key
operator: In
values:
- example-workloads-value
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: example.io/num-cpus
operator: Gt
values:
- 8
-
Infrastructure resources are placed on nodes labeled
example.io/example-infra-key = example-value. -
Workloads are placed on nodes labeled
example.io/example-workloads-key = example-workloads-value. - Nodes that have more than eight CPUs are preferred for workloads, but if they are not available, pods are still scheduled.
Example HyperConverged object with tolerations rule:
apiVersion: hco.kubevirt.io/v1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
namespace: openshift-cnv
spec:
deployment:
nodePlacements:
workload:
tolerations:
- key: "key"
operator: "Equal"
value: "virtualization"
effect: "NoSchedule"
Nodes reserved for OpenShift Virtualization components are labeled with the key = virtualization:NoSchedule taint. Only pods with matching tolerations are scheduled on reserved nodes.
The following pods are affected by the HyperConverged object node placement rules. These pods are created when an HyperConverged CR is deployed:
-
cdi-apiserver -
cdi-deployment -
cdi-uploadproxy -
kubemacpool-cert-manager -
kubemacpool-mac-controller-manager -
kubevirt-apiserver-proxy -
kubevirt-console-plugin -
kubevirt-ipam-controller-manager -
kubevirt-migration-controller -
virt-api -
virt-controller -
virt-exportproxy -
virt-template-validator
5.3.3.3. HostPathProvisioner object node placement rule example リンクのコピーリンクがクリップボードにコピーされました!
You can edit the HostPathProvisioner object directly or by using the web console.
You must schedule the hostpath provisioner (HPP) and the OpenShift Virtualization components on the same nodes. Otherwise, virtualization pods that use the hostpath provisioner cannot run. You cannot run virtual machines.
After you deploy a virtual machine (VM) with the HPP storage class, you can remove the hostpath provisioner pod from the same node by using the node selector. However, you must first revert that change, at least for that specific node, and wait for the pod to run before trying to delete the VM.
You can configure node placement rules by specifying nodeSelector, affinity, or tolerations for the spec.workload field of the HostPathProvisioner object that you create when you install the hostpath provisioner.
Example HostPathProvisioner object with nodeSelector rule:
apiVersion: hostpathprovisioner.kubevirt.io/v1beta1
kind: HostPathProvisioner
metadata:
name: hostpath-provisioner
spec:
imagePullPolicy: IfNotPresent
pathConfig:
path: "</path/to/backing/directory>"
useNamingPrefix: false
workload:
nodeSelector:
example.io/example-workloads-key: example-workloads-value
Workloads are placed on nodes labeled example.io/example-workloads-key = example-workloads-value.
5.3.4. Configure VM node placement on IBM Z mixed-node clusters リンクのコピーリンクがクリップボードにコピーされました!
On IBM Z® (s390x) clusters, OpenShift Virtualization only supports VMs on bare metal LPAR nodes. Without a nodeSelector rule, the scheduler can place VM workloads on incompatible z/VM or KVM guest nodes, causing VM pods to enter a crash loop.
By patching the HyperConverged custom resource (CR), you can restrict both OpenShift Virtualization infrastructure components and VM workloads to bare metal LPAR nodes in a single declarative configuration. The Node Feature Discovery (NFD) Operator automatically labels bare metal LPAR nodes with feature.node.kubernetes.io/cpu-model.hypervisor: PR_SM by reading /proc/cpuinfo at node boot. You can use this label as a reliable discriminator for LPAR-only placement.
Prerequisites
- Your cluster has bare metal LPAR compute nodes on IBM Z® or IBM® LinuxONE hardware.
-
You have installed the Node Feature Discovery (NFD) Operator and an active
NodeFeatureDiscoveryinstance is running. - You have installed OpenShift Virtualization.
-
You have installed the OpenShift CLI (
oc). - You are logged in with cluster administrator permissions.
Procedure
Verify that the NFD Operator has labeled the LPAR nodes by running the following command:
$ oc get nodes -L feature.node.kubernetes.io/cpu-model.hypervisorExample output
worker-lpar PR_SM worker-zvm z_VM_7.4.0 worker-kvm KVM_LinuxNodes labeled
PR_SMare valid VM targets. Nodes labeledKVM_Linuxorz_VM_7.4.0are not supported VM targets.Patch the
HyperConvergedCR to restrict OpenShift Virtualization infrastructure components and VM workloads toPR_SMnodes by running the following command:$ oc patch hyperconverged kubevirt-hyperconverged -n openshift-cnv \ --type=merge -p ' spec: infra: nodePlacement: nodeSelector: feature.node.kubernetes.io/cpu-model.hypervisor: "PR_SM" workloads: nodePlacement: nodeSelector: feature.node.kubernetes.io/cpu-model.hypervisor: "PR_SM" 'where:
spec.infra.nodePlacement-
Specifies the node placement for OpenShift Virtualization infrastructure components, including
virt-handler. Setting this field preventsvirt-handlerrollout failures on non-LPAR worker nodes. spec.workloads.nodePlacementSpecifies the default scheduling placement for all VM pods (
virt-launcher) across the cluster, ensuring that VMs start only onPR_SMLPAR nodes without requiring per-VMnodeSelectordefinitions.NoteIn environments where
spec.infra.nodePlacementdoes not fully preventvirt-handlerscheduling on non-LPAR nodes, you can protect those nodes by applying a taint.$ oc adm taint nodes <non_lpar_node> kubevirt.io/no-virt=true:NoSchedule
Verification
Verify that
virt-handlerpods are running only onPR_SMLPAR nodes by running the following command:$ oc get pods -n openshift-cnv -l kubevirt.io=virt-handler -o wideConfirm that no
virt-handlerpods are running on nodes labeledKVM_Linuxorz_VM_7.4.0.Verify that the HyperConverged Operator is healthy by running the following command:
$ oc get hyperconverged kubevirt-hyperconverged -n openshift-cnvThe output must show
Available: TrueandDegraded: False.Optional: Deploy a test VM without a
nodeSelectorto confirm cluster-wide placement by running the following command:$ oc apply -f - <<EOF apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: test-vm-placement namespace: default spec: runStrategy: Always template: spec: domain: devices: disks: - disk: bus: virtio name: containerdisk resources: requests: memory: 512Mi volumes: - containerDisk: image: quay.io/kubevirt/cirros-container-disk-demo:latest name: containerdisk EOFVerify that the test VM runs on a
PR_SMLPAR node by running the following command:$ NODE=$(oc get pod -n default -l vm.kubevirt.io/name=test-vm-placement \ -o jsonpath='{.items[0].spec.nodeName}') && \ echo "Scheduled node: $NODE" && \ oc get node "$NODE" -L feature.node.kubernetes.io/cpu-model.hypervisorThe node must report
PR_SMin theCPU-MODEL.HYPERVISORcolumn.Delete the test VM by running the following command:
$ oc delete vm test-vm-placement -n default
5.4. Postinstallation network configuration リンクのコピーリンクがクリップボードにコピーされました!
By default, OpenShift Virtualization uses a single internal pod network after installation.
After you install OpenShift Virtualization, you can install networking Operators and configure additional networks.
- You must install the Kubernetes NMState Operator to configure a Linux bridge network for live migration or external access to virtual machines (VMs).
- You can install the SR-IOV Operator to manage SR-IOV network devices and network attachments.
- You can add the MetalLB Operator to manage the lifecycle for an instance of MetalLB on your cluster.
5.4.1. Create a Linux bridge node network configuration policy リンクのコピーリンクがクリップボードにコピーされました!
You can configure a Linux bridge network for live migration or external access to virtual machines (VMs) by creating a NodeNetworkConfigurationPolicy (NNCP) manifest.
Prerequisites
- You have installed the Kubernetes NMState Operator.
Procedure
Configure the
NNCPmanifest. This example includes sample values that you must replace with your own information.apiVersion: nmstate.io/v1 kind: NodeNetworkConfigurationPolicy metadata: name: br1-eth1-policy spec: desiredState: interfaces: - name: br1 description: Linux bridge with eth1 as a port type: linux-bridge state: up ipv4: enabled: false bridge: options: stp: enabled: false port: - name: eth1-
metadata.name: Defines the name of the node network configuration policy. -
spec.desiredState.interfaces.name: Defines the name of the new Linux bridge. -
spec.desiredState.interfaces.description: Optional field that can be used to define a human-readable description for the bridge. -
spec.desiredState.interfaces.type: Defines the interface type. In this example, the type is a Linux bridge. -
spec.desiredState.interfaces.state: Defines the requested state for the interface after creation. -
spec.desiredState.interfaces.ipv4.enabled: Defines whether the ipv4 protocol is active. Setting this tofalsedisables IPv4 addressing on this bridge. -
spec.desiredState.interfaces.bridge.options.stp.enabled: Defines whether Spanning Tree Protocol (STP) is active. Setting this tofalsedisables STP on this bridge. spec.desiredState.interfaces.bridge.port.name: Defines the node NIC that the bridge is attached to.NoteTo create the NNCP manifest for a Linux bridge using Open Systems Adapter (OSA) with IBM Z®, you must disable VLAN filtering by the setting the
rx-vlan-filtertofalsein theNodeNetworkConfigurationPolicymanifest.Alternatively, if you have SSH access to the node, you can disable VLAN filtering by running the following command:
$ sudo ethtool -K <osa-interface-name> rx-vlan-filter off
-
Create the
NNCPmanifest:$ oc apply -f linux-bridge-nncp.yaml
5.4.2. Create a Linux bridge NAD by using the web console リンクのコピーリンクがクリップボードにコピーされました!
Use the OpenShift Container Platform web console to create a NetworkAttachmentDefinition (net-attach-def) that connects pods and virtual machines to a layer-2 network.
Configuring IP address management (IPAM) in a network attachment definition for virtual machines is not supported.
Procedure
-
In the web console, click Networking
NetworkAttachmentDefinitions. Click Create Network Attachment Definition.
NoteThe network attachment definition must be in the same namespace as the pod or virtual machine.
- Enter a unique Name and optional Description.
- Select CNV Linux bridge from the Network Type list.
- Enter the name of the bridge in the Bridge Name field.
Optional: If the resource has VLAN IDs configured, enter the ID numbers in the VLAN Tag Number field.
NoteOpen Systems Adapter (OSA) interfaces on IBM Z® do not support VLAN filtering and drop VLAN-tagged traffic. Avoid using VLAN-tagged
NetworkAttachmentDefinitionswith OSA interfaces.- Optional: Select MAC Spoof Check to enable MAC spoof filtering. This feature provides security against a MAC spoofing attack by allowing only a single MAC address to exit the pod.
Optional: In the YAML tab, add the
spec.config.disableContainerInterfacefield. When set totrue, the Bridge CNI plug-in skips creating a standard container virtual ethernet (veth) interface inside the pod’s network namespace. This enables the virtualization networking backend to attach the layer-2 interface directly to the guest VM instead of a standard container.Example YAML:
apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: bridge-network annotations: k8s.v1.cni.cncf.io/resourceName: bridge.network.kubevirt.io/br1 spec: config: | { # ... "disableContainerInterface": true, # ... }- Click Create.
5.4.3. Configure a dedicated secondary network for live migration リンクのコピーリンクがクリップボードにコピーされました!
Configure a dedicated secondary network for live migration to minimize the effects of network saturation on tenant workloads during live migration.
Prerequisites
-
You installed the OpenShift CLI (
oc). -
You logged in to the cluster as a user with the
cluster-adminrole. - Each node has at least two Network Interface Cards (NICs).
- The NICs for live migration are connected to the same VLAN.
- You have configured a Linux bridge network.
Procedure
Create a
NetworkAttachmentDefinitionmanifest according to the following example:apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: my-secondary-network namespace: openshift-cnv spec: config: '{ "cniVersion": "0.3.1", "name": "migration-bridge", "type": "macvlan", "master": "eth1", "mode": "bridge", "ipam": { "type": "whereabouts", "range": "10.200.5.0/24" } }'-
metadata.name: Defines the name of theNetworkAttachmentDefinitionobject. -
config.master: Defines the name of the NIC to be used for live migration. -
config.type: Defines the name of the CNI plugin that provides the network for theNetworkAttachmentDefinition. -
config.range: Defines an IP address range for the secondary network. This range must not overlap the IP addresses of the main network.
-
Open the
HyperConvergedCR in your default editor by running the following command:$ oc edit hco kubevirt-hyperconverged -n openshift-cnvAdd the name of the
NetworkAttachmentDefinitionobject to thespec.virtualization.liveMigrationConfigstanza of theHyperConvergedCR.Example
HyperConvergedmanifest:apiVersion: hco.kubevirt.io/v1 kind: HyperConverged metadata: name: kubevirt-hyperconverged namespace: openshift-cnv spec: virtualization: liveMigrationConfig: completionTimeoutPerGiB: 800 network: <network> parallelMigrationsPerCluster: 5 parallelOutboundMigrationsPerNode: 2 progressTimeout: 150 # ...-
spec.virtualization.liveMigrationConfig.network: Defines the name of the MultusNetworkAttachmentDefinitionobject to be used for live migrations.
-
-
Save your changes and exit the editor. The
virt-handlerpods restart and connect to the secondary network.
Verification
When the node that the virtual machine runs on is placed into maintenance mode, the VM automatically migrates to another node in the cluster. You can verify that the migration occurred over the secondary network and not the default pod network by checking the target IP address in the virtual machine instance (VMI) metadata.
$ oc get vmi <vmi_name> -o jsonpath='{.status.migrationState.targetNodeAddress}'
5.4.4. Select a dedicated migration network by using the web console リンクのコピーリンクがクリップボードにコピーされました!
You can select a dedicated network for live migration by using the OpenShift Container Platform web console.
Prerequisites
- You configured a Multus network for live migration.
- You created a network attachment definition for the network.
Procedure
-
Go to Virtualization
Settings in the OpenShift Container Platform web console. - On the Cluster tab, click General settiings.
- Click Live Migration.
- Select the network from the Live migration network list.
5.4.5. Configure SR-IOV network devices リンクのコピーリンクがクリップボードにコピーされました!
The SR-IOV Network Operator adds the SriovNetworkNodePolicy.sriovnetwork.openshift.io custom resource definition (CRD) to OpenShift Container Platform. You can configure an SR-IOV network device by creating a SriovNetworkNodePolicy custom resource (CR).
When applying the configuration specified in a SriovNetworkNodePolicy CR, the SR-IOV Operator might drain the nodes, and in some cases, reboot nodes. Reboot only happens in the following cases:
-
With Mellanox NICs (
mlx5driver) a node reboot happens every time the number of virtual functions (VFs) increase on a physical function (PF). -
With Intel NICs, a reboot only happens if the kernel parameters do not include
intel_iommu=onandiommu=pt.
It might take several minutes for a configuration change to apply.
Prerequisites
-
You installed the OpenShift CLI (
oc). -
You have access to the cluster as a user with the
cluster-adminrole. - You have installed the SR-IOV Network Operator.
- You have enough available nodes in your cluster to handle the evicted workload from drained nodes.
- You have not selected any control plane nodes for SR-IOV network device configuration.
Procedure
Create an
SriovNetworkNodePolicyobject, and then save the YAML in the<name>-sriov-node-network.yamlfile. Replace<name>with the name for this configuration.apiVersion: sriovnetwork.openshift.io/v1 kind: SriovNetworkNodePolicy metadata: name: <name> namespace: openshift-sriov-network-operator spec: resourceName: <sriov_resource_name> nodeSelector: feature.node.kubernetes.io/network-sriov.capable: "true" priority: <priority> mtu: <mtu> numVfs: <num> nicSelector: vendor: "<vendor_code>" deviceID: "<device_id>" pfNames: ["<pf_name>", ...] rootDevices: ["<pci_bus_id>", "..."] deviceType: vfio-pci isRdma: false-
metadata.namedefines a name for theSriovNetworkNodePolicyobject. -
metadata.namespacedefines the namespace where the SR-IOV Network Operator is installed. -
spec.resourceNamedefines the resource name of the SR-IOV device plugin. You can create multipleSriovNetworkNodePolicyobjects for a resource name. -
spec.nodeSelector.feature.node.kubernetes.io/network-sriov.capabledefines the node selector to select which nodes are configured. Only SR-IOV network devices on selected nodes are configured. The SR-IOV Container Network Interface (CNI) plugin and device plugin are deployed only on selected nodes. -
spec.priorityis an optional field that defines an integer value between0and99. A smaller number gets higher priority, so a priority of10is higher than a priority of99. The default value is99. -
spec.mtuis an optional field that defines a value for the maximum transmission unit (MTU) of the virtual function. The maximum MTU value can vary for different NIC models. -
spec.numVfsdefines the number of the virtual functions (VF) to create for the SR-IOV physical network device. For an Intel network interface controller (NIC), the number of VFs cannot be larger than the total VFs supported by the device. For a Mellanox NIC, the number of VFs cannot be larger than127. spec.nicSelectordefines the Ethernet device for the Operator to configure. You do not need to specify values for all the parameters.NoteIt is recommended to identify the Ethernet adapter with enough precision to minimize the possibility of selecting an Ethernet device unintentionally. If you specify
rootDevices, you must also specify a value forvendor,deviceID, orpfNames.If you specify both
pfNamesandrootDevicesat the same time, ensure that they point to an identical device.-
spec.nicSelector.vendoris an optional field that defines the vendor hex code of the SR-IOV network device. The only allowed values are either8086or15b3. -
spec.nicSelector.deviceIDis an optional field that defines the device hex code of SR-IOV network device. The only allowed values are158b,1015,1017. -
spec.nicSelector.pfNamesis an optional field that defines an array of one or more physical function (PF) names for the Ethernet device. -
spec.nicSelector.rootDevicesis an optional field that defines an array of one or more PCI bus addresses for the physical function of the Ethernet device. Provide the address in the following format:0000:02:00.1. -
spec.deviceTypedefines the driver type. Thevfio-pcidriver type is required for virtual functions in OpenShift Virtualization. spec.isRdmais an optional field that defines whether to enable remote direct memory access (RDMA) mode. For a Mellanox card, setisRdmatofalse. The default value isfalse.NoteIf
isRDMAflag is set totrue, you can continue to use the RDMA enabled VF as a normal network device. A device can be used in either mode.
-
-
Optional: Label the SR-IOV capable cluster nodes with
SriovNetworkNodePolicy.Spec.NodeSelectorif they are not already labeled. For more information about labeling nodes, see "Understanding how to update labels on nodes". Create the
SriovNetworkNodePolicyobject. When running the following command, replace<name>with the name for this configuration:$ oc create -f <name>-sriov-node-network.yamlAfter applying the configuration update, all the pods in the
sriov-network-operatornamespace change to theRunningstatus.To verify your SR-IOV network device configuration, enter the following command and replace
<node_name>with the name of the node where you configured the device.$ oc get sriovnetworknodestates -n openshift-sriov-network-operator <node_name> -o jsonpath='{.status.syncStatus}'
5.4.6. Enable load balancer services by using the web console リンクのコピーリンクがクリップボードにコピーされました!
You can enable the creation of load balancer services for a virtual machine (VM) from the OpenShift Container Platform web console. This setting must be on before you can create a load balancer service for SSH access.
Prerequisites
- You have configured a load balancer for the cluster.
-
You have logged in as a user with the
cluster-adminrole. - You created a network attachment definition for the network.
Procedure
-
Go to Virtualization
Settings. - Click Cluster.
- Expand General settings and SSH configuration.
- Set SSH over LoadBalancer service to on.
5.4.7. Configure additional routes to the cdi-uploadproxy service リンクのコピーリンクがクリップボードにコピーされました!
Configure additional routes to the cdi-uploadproxy service to enable users to upload virtual machine images from outside the cluster.
Prerequisites
-
You installed the OpenShift CLI (
oc). -
You logged in to the cluster as a user with the
cluster-adminrole.
Procedure
Configure the route to the external host by running the following command:
$ oc create route reencrypt <route_name> -n openshift-cnv \ --insecure-policy=Redirect \ --hostname=<host_name_or_address> \ --service=cdi-uploadproxywhere:
<route_name>- Specifies the name to assign to this custom route.
<host_name_or_address>- Specifies the fully qualified domain name or IP address of the external host providing image upload access.
Run the following command to annotate the route. This ensures that the correct Containerized Data Importer (CDI) CA certificate is injected when certificates are rotated:
$ oc annotate route <route_name> -n openshift-cnv \ operator.cdi.kubevirt.io/injectUploadProxyCert="true"where:
<route_name>- Specifies the name of the route you created.
5.5. Postinstallation storage configuration リンクのコピーリンクがクリップボードにコピーされました!
After you install OpenShift Virtualization, you must configure a default storage class. Configuring a storage class allows your cluster to receive automated boot source updates. If your storage provider is not recognized by the Containerized Data Importer (CDI), you must configure storage profiles after you install OpenShift Virtualization. Storage profiles provide recommended storage settings based on the associated storage class.
Optional: You can configure local storage by using the hostpath provisioner (HPP).
See the "Storage configuration overview" documentation for more options, including configuring the CDI, data volumes, and automatic boot source updates.
5.5.1. Configuring local storage by using the HPP リンクのコピーリンクがクリップボードにコピーされました!
When you install the OpenShift Virtualization Operator, the Hostpath Provisioner (HPP) Operator is automatically installed. The HPP Operator creates the HPP provisioner.
The HPP is a local storage provisioner designed for OpenShift Virtualization. To use the HPP, you must create an HPP custom resource (CR).
HPP storage pools must not be in the same partition as the operating system. Otherwise, the storage pools might fill the operating system partition. If the operating system partition is full, this might negatively impact performance, or the node can become unstable or unusable.
5.5.1.1. Create a storage class for the CSI driver with the storagePools stanza リンクのコピーリンクがクリップボードにコピーされました!
To use the hostpath provisioner (HPP) you must create an associated storage class for the Container Storage Interface (CSI) driver.
When you create a storage class, you set parameters that affect the dynamic provisioning of persistent volumes (PVs) that belong to that storage class. You cannot update a StorageClass object’s parameters after you create it.
Procedure
Create a
storageclass_csi.yamlfile to define the storage class:apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: hostpath-csi provisioner: kubevirt.io.hostpath-provisioner reclaimPolicy: Delete volumeBindingMode: WaitForFirstConsumer parameters: storagePool: my-storage-pool-
reclaimPolicydefines whether the underlying storage is deleted or retained when a user deletes a PVC. The two possiblereclaimPolicyvalues areDeleteandRetain. If you do not specify a value, the default value isDelete. volumeBindingModedefines the timing of PV creation. In this example, theWaitForFirstConsumerconfiguration delays PV creation until the scheduler assigns a pod to a specific node.NoteVirtual machines use data volumes based on local PVs, which reside on specific nodes. When the system prepares a disk image for the virtual machine, the scheduler might not place the virtual machine on the node where it pinned the local storage PV.
+ To solve this problem, use the Kubernetes pod scheduler to bind the persistent volume claim (PVC) to a PV on the correct node. Setting the
volumeBindingModeparameter of theStorageClasstoWaitForFirstConsumerdelays PV binding and provisioning until you create a pod that uses the PVC.-
parameters.storagePooldefines the name of the storage pool defined in the HPP custom resource (CR).
-
- Save the file and exit.
Create the
StorageClassobject by running the following command:$ oc create -f storageclass_csi.yaml
5.6. Self validation checkup リンクのコピーリンクがクリップボードにコピーされました!
A self validation checkup runs conformance tests on critical subsystems to verify that the environment is fully functional and self-sustained before you deploy production workloads.
5.6.1. Run a self validation checkup in the web console リンクのコピーリンクがクリップボードにコピーされました!
Running a self validation checkup streamlines the process of running functional tests, which enables you to validate the stability, health, and compliance of an OpenShift Virtualization installation before deploying workloads.
Prerequisites
- You have cluster administrator permissions.
- You have access to an OpenShift Container Platform cluster where OpenShift Virtualization is installed.
- You are logged in to the OpenShift Container Platform web console.
Procedure
-
In the OpenShift Container Platform web console, go to Virtualization
Checkups. - Go to the Self validation tab.
- Click Run checkup.
- Configure settings for the test that you want to run.
- Optional: You can enable a dry run test by clicking Advanced settings and then toggling the Dry run button.
Click Run. The Self validation checkup details page is displayed.
You can observe the self validation checkup running in real time. The test can take several hours to complete.
- After the test is complete, you can view high-level results in the Self validation checkup details page, including the names of any failing tests.
- Optional: You can download detailed results as a ZIP file by clicking Download results in the Self validation checkup details page.
5.7. Allocate physical cores for virtual machines リンクのコピーリンクがクリップボードにコピーされました!
As a cluster administrator, you can allocate a full physical core to a specific virtual machine (VM), instead of allowing different VMs to share the same physical core. Configuring your VMs to use only full physical cores can optimize performance for high-throughput or latency-critical VMs.
Allocating only full physical cores is important on simultaneous multi-threading (SMT) enabled systems because it offers the following benefits:
- Prevents noisy neighbors and resource contention
- Mitigates performance degradation
- Offers predictable latency
- Guarantees exclusive CPU resources
5.7.1. Configure full physical core allocation for virtual machines リンクのコピーリンクがクリップボードにコピーされました!
You can configure full physical core allocation by modifying the cpuManagerPolicy and cpuManagerPolicyOptions settings in the KubeletConfig custom resource (CR). Whole-core allocation gives a VM exclusive use of its cores, which prevents contention with other workloads on the node.
Prerequisites
- You have cluster administrator access to a OpenShift Container Platform cluster with OpenShift Virtualization installed.
-
You have installed the OpenShift CLI (
oc). - You have enabled CPU Manager on the node where your VM runs.
Procedure
Edit the
KubeletConfigCR to add the requiredcpuManagerPolicyandcpuManagerPolicyOptionsconfigurations:apiVersion: machineconfiguration.openshift.io/v1 kind: KubeletConfig # ... cpuManagerPolicy: static cpuManagerPolicyOptions: full-pcpus-only: true kubeReserved: cpu: "1" # ...-
You must set the
cpuManagerPolicy: staticpolicy to enable exclusive CPU allocation. This setting is a prerequisite for configuring thecpuManagerPolicyOptionssettings. -
You must set the
full-pcpus-only: truepolicy option so that the static CPU Manager policy only allocates full physical cores. -
You must reserve 1 CPU for the system by setting
cpu: "1"in thekubeReservedsettings. This ensures that the cluster remains stable, by requiring that the system’s core functions always have access to the CPU that they need to work correctly.
-
You must set the
Run the following command to apply the changes to the
KubeletConfigCR:$ oc apply -f <filename>.yaml
Verification
Inspect the kubelet configuration on a node where the change you applied the change, by running the following command and inspecting the output:
$ oc debug node/<node_name> -- chroot /host cat /etc/kubernetes/kubelet.conf | grep -E -A 2 'cpuManagerPolicy|kubeReserved'Example output:
cpuManagerPolicy: static cpuManagerPolicyOptions: full-pcpus-only: true -- kubeReserved: cpu: "1"
5.8. Configure higher VM workload density リンクのコピーリンクがクリップボードにコピーされました!
You can increase the number of virtual machines (VMs) on nodes by overcommitting memory (RAM). You overcommit memory by provisioning swap storage on worker nodes. This is useful when you have many similar or underused workloads.
Memory overcommitment can lower workload performance on a highly utilized system.
5.8.1. Swap provisioning methods リンクのコピーリンクがクリップボードにコピーされました!
You can provision swap storage on worker nodes by using either an NVMe partition or a file-based approach. The method you choose depends on your hardware configuration and performance requirements.
NVMe partition-based swap requires a dedicated NVMe device on each worker node and provides better performance for production workloads with heavy memory overcommitment. This method is permanent and requires repartitioning to remove.
File-based swap uses existing filesystem space and works on any worker node without dedicated hardware. This method has slower I/O performance than partition-based swap but is easier to provision and remove. Use this method for testing, development, or production clusters where dedicated NVMe devices are not available.
5.8.2. Swap space requirements リンクのコピーリンクがクリップボードにコピーされました!
The swap space that you provision on a node must be at least equal to the overcommitted RAM. This requirement applies to both NVMe partition-based swap and file-based swap.
Calculate the amount of swap space to provision on a node by using the following formula:
NODE_SWAP_SPACE = NODE_RAM * (MEMORY_OVER_COMMIT_PERCENT / 100% - 1)
Example:
NODE_SWAP_SPACE = 16 GB * (150% / 100% - 1)
= 16 GB * (1.5 - 1)
= 16 GB * (0.5)
= 8 GB
5.8.3. Provision swap on an NVMe device リンクのコピーリンクがクリップボードにコピーされました!
You can provision a dedicated NVMe device for swap. The virt-platform-autopilot controller automatically enables a swap partition labeled OCPSWAP for virtualization workloads. Use this method for production clusters requiring better performance.
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You are logged in to the cluster with the
cluster-adminrole. -
You have installed OpenShift Virtualization. The
virt-platform-autopilotcontroller is enabled by default. - The worker node has a dedicated NVMe device.
- The NVMe device has enough capacity for the node’s worst-case memory overcommitment.
Procedure
Select a worker node where you want to enable memory overcommitment and start a debug session by running the following command:
$ oc debug node/<node_name>Replace
<node_name>with the name of the worker node.Enter the host context by running the following command:
$ chroot /hostList the available NVMe disks and their World Wide Names (WWNs) by running the following command:
$ lsblk -p -o +WWNExample output
NAME TYPE MODEL SERIAL REV TRAN RQ-SIZE MQ WWN /dev/nvme0n1 disk KXG8AZNV512G LA KIOXIA 63QFXXXXXXEU 5108APLA nvme 1023 12 eui.8ce38e0500e775a4Find the device path by using its WWN. The path follows the
/dev/disk/by-id/nvme-<WWN>format. Run the following command, replacing<WWN>with the value from the previous command:$ ls /dev/disk/by-id/nvme-<WWN>Example output
/dev/disk/by-id/nvme-eui.8ce38e0500e775a4Create a GUID Partition Table (GPT) partition table and an
OCPSWAPpartition by running the following command, replacing<WWN>with the WWN of the selected device:WarningThe following command erases all data on the selected NVMe device. Back up any data that you need to retain before you continue.
$ echo -e 'label: gpt\nname="OCPSWAP", type=swap' | sfdisk --wipe always /dev/disk/by-id/nvme-<WWN>The partition name must be
OCPSWAPso that thevirt-platform-autopilotcontroller can discover and enable the partition.WarningOnly one partition on the node can use the
OCPSWAPlabel. If more than one partition uses this label, the/dev/disk/by-partlabel/OCPSWAPpath does not resolve deterministically, and later commands can format or enable the wrong partition.Format the partition as Linux swap and set its filesystem label to
OCPSWAPby running the following command:$ mkswap -L OCPSWAP /dev/disk/by-partlabel/OCPSWAPThe
/dev/disk/by-partlabel/OCPSWAPpath resolves to the partition that you created in the previous step. The-L OCPSWAPoption sets the swap filesystem label, which thevirt-platform-autopilotcontroller uses to identify the swap partition. You must format the partition, not the whole NVMe device.Verify the swap partition before rebooting the node by running the following commands:
$ swapon /dev/disk/by-partlabel/OCPSWAP $ free -mExample output
total used free shared buff/cache available Mem: 31728 20964 906 4586 12269 10764 Swap: 8191 95 8096Reboot the node by running the following command:
$ systemctl reboot
Verification
After the node reboots, start a debug session by running the following command:
$ oc debug node/<node_name>Enter the host context by running the following command:
$ chroot /hostVerify that the
virt-platform-autopilotcontroller discovered the swap partition by running the following command:$ ls /dev/disk/by-partlabel/OCPSWAPVerify that swap space is available by running the following command:
$ free -mExample output
total used free shared buff/cache available Mem: 31728 20964 906 4586 12269 10764 Swap: 8191 95 8096
5.8.4. Provision swap by using a file リンクのコピーリンクがクリップボードにコピーされました!
You can provision swap by creating a file on the worker node. The MachineConfig object that you create provisions the swap file and enables it for virtualization workloads. Use this method when dedicated NVMe devices are not available.
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You are logged in to the cluster with the
cluster-adminrole. - The node belongs to a worker pool.
Procedure
Create a
MachineConfigfile with the parameters shown in the following example:apiVersion: machineconfiguration.openshift.io/v1 kind: MachineConfig metadata: labels: machineconfiguration.openshift.io/role: worker name: 90-worker-swap spec: config: ignition: version: 3.5.0 systemd: units: - contents: | [Unit] Description=Provision and enable swap ConditionFirstBoot=no ConditionPathExists=!/var/tmp/swapfile [Service] Type=oneshot Environment=SWAP_SIZE_MB=5000 ExecStart=/bin/sh -c "sudo fallocate -l ${SWAP_SIZE_MB}M /var/tmp/swapfile && \ sudo chmod 600 /var/tmp/swapfile && \ sudo mkswap /var/tmp/swapfile && \ sudo swapon /var/tmp/swapfile && \ free -h" [Install] RequiredBy=kubelet-dependencies.target enabled: true name: swap-provision.service - contents: | [Unit] Description=Enable swap ConditionFirstBoot=no ConditionPathExists=/var/tmp/swapfile [Service] Type=oneshot ExecStart=/bin/sh -c "sudo swapon /var/tmp/swapfile" [Install] RequiredBy=kubelet-dependencies.target enabled: true name: swap-enable.serviceSet the
SWAP_SIZE_MBvalue to the amount of swap space to provision on the node, in MB.Wait for the worker nodes to sync with the new configuration by running the following command:
$ oc wait mcp worker --for condition=Updated=True --timeout=-1s
Verification
View a list of worker nodes by running the following command:
$ oc get nodes -l node-role.kubernetes.io/workerSelect a node from the list and display its memory usage by running the following command:
$ oc debug node/<selected_node> -- free -mReplace
<selected_node>with the node name.The
Swap:row displays an amount greater than zero if the node has swap enabled.Example output
total used free shared buff/cache available Mem: 31846 23155 1044 6014 14483 8690 Swap: 8191 2337 5854
5.8.5. Remove swap from an NVMe device リンクのコピーリンクがクリップボードにコピーされました!
You can remove a swap partition from an NVMe device, freeing the device for other use. The node must be placed in maintenance mode before you remove the swap partition.
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You are logged in to the cluster with the
cluster-adminrole. -
The worker node has an NVMe swap partition labeled
OCPSWAP.
Procedure
-
Place the node in maintenance mode by using the
oc adm cordonandoc adm draincommands. Verify that all pod and VM workloads are evicted from the node by running the following commands:
$ oc get pods --all-namespaces --field-selector spec.nodeName=<node_name>$ oc get vmi -A --field-selector spec.nodeName=<node_name>Only DaemonSet pods should remain on the node.
Start a debug session by running the following command:
$ oc debug node/<node_name>Replace
<node_name>with the name of the worker node.Enter the host context by running the following command:
$ chroot /hostDisable the swap partition by running the following command:
$ swapoff /dev/disk/by-partlabel/OCPSWAPVerify that swap is disabled by running the following command:
$ free -mExample output
total used free shared buff/cache available Mem: 31728 20964 906 4586 12269 10764 Swap: 0 0 0The
Swap:row displays zero values when swap is disabled.NoteIf the
Swap:row shows non-zero values, the swap partition is still active. Verify that all workloads are evacuated and retry theswapoffcommand. If the issue persists, reboot the node to force swap deactivation.Remove the swap partition:
Set the
$DISKvariable to the disk device path by running the following command:$ DISK="/dev/$(lsblk -no PKNAME /dev/disk/by-partlabel/OCPSWAP)"Delete the partition by running the following command:
WarningThis command removes all partitions on the device, not just the
OCPSWAPpartition. If you manually created additional partitions on this device, they will be deleted.$ sfdisk --delete $DISK
Verify that the
OCPSWAPpartition label is removed by running the following command:$ ls /dev/disk/by-partlabel/OCPSWAPExample output
ls: cannot access '/dev/disk/by-partlabel/OCPSWAP': No such file or directoryNoteIf the partition label still exists after running
sfdisk --delete, verify the correct disk device was used and retry the deletion command. Reboot the node if the partition table was not updated.Exit the debug session by running the following commands:
$ exit$ exitThe first
exitcommand leaves the chroot environment. The secondexitcommand terminates the debug pod.-
Remove the node from maintenance mode by using the
oc adm uncordoncommand.
5.8.6. Enable memory overcommitment and provision swap リンクのコピーリンクがクリップボードにコピーされました!
You can increase the number of virtual machines (VMs) on a node by overcommitting memory and provisioning swap resources. When you enable memory overcommitment, the virt-platform-autopilot controller automatically deploys the necessary node-level configurations.
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You are logged in to the cluster with the
cluster-adminrole. - You have defined a memory overcommit ratio.
- You have provisioned swap storage on worker nodes.
Procedure
Choose one of the following methods to enable memory overcommitment in OpenShift Virtualization:
After you enable memory overcommitment, only virtual machine workloads (VM pods) of the
BurstableQuality of Service (QoS) class can use swap resources. VM pods of theGuaranteedQoSclass and pods of anyQoSclass that do not belong to VMs cannot use swap resources. For descriptions ofQoSclasses, see Configure Quality of Service for Pods (Kubernetes documentation).When you configure virtual machines for memory overcommitment, use
spec.domain.memory.guestin the VM manifest. Usingspec.domain.resources.requests.memorydisables the memory overcommit configuration.To use the web console:
-
In the OpenShift Container Platform web console, go to Virtualization
Settings. - Click the Cluster tab.
- Expand General settings.
- Expand Memory request ratio.
In the Request ratio field, enter a value from 25 to 100.
The request ratio is the percentage of each virtual machine’s configured memory that the cluster requests. A lower ratio increases overcommitment. At a ratio of 25%, a VM configured with 4 GiB of memory requests 1 GiB on the cluster. At a ratio of 100%, it requests the full 4 GiB.
The web console indicates the level of risk for the value you enter. It shows Recommended at 75% or greater, Use with caution from 50% to 74.9%, and High overcommit risk from 25% to 49.9%.
The Active ratio line shows the ratio currently calculated across all virtual machines on the cluster, which can differ from the ratio you request. It shows
No running VMsif no virtual machines are running.- Click Save.
-
In the OpenShift Container Platform web console, go to Virtualization
To use the CLI, run the following command to enable higher memory density and set the overcommit rate:
$ oc patch -n openshift-cnv hco kubevirt-hyperconverged --type='json' -p='[ \ { \ "op": "replace", \ "path": "/spec/virtualization/higherWorkloadDensity/memoryOvercommitPercentage", \ "value": 150 \ } \ ]'Example output
hyperconverged.hco.kubevirt.io/kubevirt-hyperconverged patched
Verification
Verify the OpenShift Virtualization memory overcommitment configuration by running the following command:
$ oc get -n openshift-cnv hco kubevirt-hyperconverged -o jsonpath='{.spec.virtualization.higherWorkloadDensity}{"\n"}'Example output
{"memoryOvercommitPercentage":150}The returned value must match the value you configured earlier.
5.8.7. Disable memory overcommitment and remove swap リンクのコピーリンクがクリップボードにコピーされました!
You can disable higher virtual machine (VM) workload density if you no longer need memory overcommitment, and remove the associated swap resources from your cluster.
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You are logged in to the cluster with the
cluster-adminrole.
Procedure
Revert the memory overcommitment configuration by running the following command:
$ oc patch -n openshift-cnv hco kubevirt-hyperconverged \ --type='json' \ -p='[{"op": "remove", "path": "/spec/virtualization/higherWorkloadDensity"}]'Delete the
MachineConfigobjects that provision and configure swap by running the following commands:$ oc delete machineconfig 90-worker-swap$ oc delete machineconfig 90-worker-swap-onlineWait for the worker nodes to sync with the new configuration by running the following command:
$ oc wait mcp worker --for condition=Updated=True --timeout=-1s
Verification
Confirm that swap is no longer enabled on a node by running the following command:
$ oc debug node/<selected_node> -- free -mEnsure that the
Swap:row shows0or that no swap space is provisioned.
5.9. Virtual machine recovery from node failures リンクのコピーリンクがクリップボードにコピーされました!
To ensure that virtual machines (VMs) recover automatically when a node fails, configure node health checks, automated remediation, and capacity planning. These recommendations come from chaos testing results and help minimize VM downtime during node failure conditions.
5.9.1. How node health monitoring protects virtual machines リンクのコピーリンクがクリップボードにコピーされました!
By default, virtual machines (VMs) are not automatically recovered to other available nodes when a node fails. To minimize VM downtime and ensure workload resilience, configure node health monitoring and automated remediation.
Without the Node Health Check Operator and a remediation Operator such as Self Node Remediation (SNR) or Fence Agents Remediation (FAR), VMs experience downtime until the node recovers. Apply the following configurations to ensure your workloads are resilient under node failure conditions:
-
Configure VMs with
runStrategy: Alwaysto allow recovery to other available nodes. - Deploy and configure the Node Health Check Operator to monitor node status changes and trigger automated remediation.
- Configure a remediation operator, such as SNR or FAR, to recover workloads from failed nodes.
- Plan node capacity to ensure that enough resources are available to host VMs that migrate from failed nodes.
5.9.1.1. Configure VM run strategy リンクのコピーリンクがクリップボードにコピーされました!
You can configure a run strategy for a virtual machine (VM) by using the command line. The run strategy controls whether a VM automatically restarts after disruptions such as node failures or maintenance events.
Prerequisites
-
You have installed the OpenShift CLI (
oc).
Procedure
Edit the
VirtualMachineresource by running the following command:$ oc edit vm <vm_name> -n <namespace>Example run strategy:
apiVersion: kubevirt.io/v1 kind: VirtualMachine spec: runStrategy: Always # ...
5.9.2. Configure node health checks for virtual machines リンクのコピーリンクがクリップボードにコピーされました!
You can configure the Node Health Check Operator to monitor node status and trigger automated remediation when a node becomes unhealthy.
Prerequisites
- You have installed the Node Health Check Operator.
- You have installed a remediation operator.
- You have cluster administrator privileges.
Procedure
Create a
NodeHealthCheckcustom resource (CR) to define the health check criteria and remediation strategy:apiVersion: remediation.medik8s.io/v1alpha1 kind: NodeHealthCheck metadata: name: nodehealthcheck-sample spec: minHealthy: <count> pauseRequests: - <pause_test_cluster> remediationTemplate: apiVersion: self-node-remediation.medik8s.io/v1alpha1 name: self-node-remediation-automatic-strategy-template namespace: openshift-workload-availability kind: SelfNodeRemediationTemplate escalatingRemediations: - remediationTemplate: apiVersion: self-node-remediation.medik8s.io/v1alpha1 name: self-node-remediation-resource-deletion-template namespace: openshift-workload-availability kind: SelfNodeRemediationTemplate order: 1 timeout: 300s selector: matchExpressions: - key: node-role.kubernetes.io/worker operator: Exists unhealthyConditions: - type: Ready status: "False" duration: 30s - type: Ready status: Unknown duration: 30swhere:
spec.minHealthydefines the number of worker nodes required to host VMs that migrate from failed nodes.- For critical environments, set this value to the minimum number of nodes that you require to maintain the cluster workload.
- For hyperconverged storage, set this value to one less than your number of nodes to limit remediation to a single worker-node failure and maintain storage stability.
-
spec.remediationTemplatedefines the remediation template to use when the Node Health Check Operator detects an unhealthy node. This example uses the Self Node Remediation Operator. -
spec.escalatingRemediationsdefines escalating remediation strategies. If the initial remediation does not resolve the issue within the specified timeout, the next remediation strategy runs. -
spec.selectordefines the nodes to monitor. This example monitors all worker nodes. -
spec.unhealthyConditionsdefines the parameters to identify an unhealthy node. spec.unhealthyConditions.durationdefines the duration that a condition must persist before remediation starts. Set lower values for faster recovery. The following table shows recommended values:Table 5.2. Recommended unhealthyConditions duration values Environment Recommended duration Critical
30-60 seconds
Standard
60-180 seconds
Conservative
180-360 seconds
Apply the
NodeHealthCheckCR by running the following command:$ oc apply -f nodehealthcheck-sample.yaml
Verification
Verify that the
NodeHealthCheckCR exists by running the following command:$ oc get nodehealthcheck nodehealthcheck-sample
If remediation does not trigger as expected, verify that the remediation Operator runs correctly, and check the NodeHealthCheck CR events for errors:
$ oc describe nodehealthcheck nodehealthcheck-sample
5.9.3. Node remediation strategies for OpenShift Virtualization リンクのコピーリンクがクリップボードにコピーされました!
Use the best remediation strategy for your environment to ensure that virtual machine (VM) workloads recover automatically when nodes become unhealthy.
Self Node Remediation (SNR) and Fence Agents Remediation (FAR) are the recommended remediation Operators for OpenShift Virtualization environments. Recovery time depends on the number of VMs on the failed nodes.
- Self Node Remediation (SNR)
- Use for nodes that do not have a management interface, or when the management interface might be unreachable. SNR does not require a management interface to function. Do not use SNR for hyperconverged storage because API unavailability can cause remediation actions that negatively impact hyperconverged storage protection domains.
- Fence Agents Remediation (FAR)
The fastest remediation Operator for workload recovery time. Use FAR when a baseboard management controller (BMC) interface is available. FAR requires a management interface that is reachable from the Kubernetes pod network.
You must use FAR for hyperconverged storage configurations. For hyperconverged storage, set the Node Health Check
minHealthyproperty to your total node count minus one. With this setting, FAR does not remediate more than a single worker-node failure within the same zone, storage placement, and replication group to maintain storage stability.
-
Remediation actions start after the node conditions monitored by the Node Health Check Operator exceed the time specified in
spec.unhealthyConditions[].duration. -
Disruption to the node running the
self-node-remediation-controller-managerpod increases recovery times.
5.9.3.1. Self Node Remediation configuration parameters リンクのコピーリンクがクリップボードにコピーされました!
You can tune the Self Node Remediation (SNR) Operator configuration to optimize recovery times and ensure availability of VM workloads.
- SelfNodeRemediationTemplate strategies
The
SelfNodeRemediationTemplatecustom resource (CR) defines the remediation strategy to use when the Node Health Check Operator identifies a node as unhealthy. Configure the remediation strategy in aSelfNodeRemediationTemplateCR:apiVersion: self-node-remediation.medik8s.io/v1alpha1 kind: SelfNodeRemediationTemplate metadata: name: self-node-remediation-resource-deletion-template namespace: openshift-operators spec: template: spec: remediationStrategy: ResourceDeletionwhere:
-
spec.remediationStrategydefines the remediation strategy. UseResourceDeletionto delete pods and associated volume attachments on the unhealthy node. UseOutOfServiceTaintto place anout-of-servicetaint on the unhealthy node and delete pods and associated volume attachments. This strategy is faster thanResourceDeletion.
-
- SelfNodeRemediationConfig parameters
The
SelfNodeRemediationConfigCR defines the timing and connectivity parameters for the SNR Operator. Tuning these parameters based on your environment conditions helps ensure availability of workloads and prevents unnecessary remediation actions. Configure the timing and connectivity parameters in aSelfNodeRemediationConfigCR:apiVersion: self-node-remediation.medik8s.io/v1alpha1 kind: SelfNodeRemediationConfig metadata: name: self-node-remediation-config namespace: openshift-operators spec: safeTimeToAssumeNodeRebootedSeconds: 180 watchdogFilePath: /dev/watchdog isSoftwareRebootEnabled: true apiServerTimeout: 15s apiCheckInterval: 5s maxApiErrorThreshold: 3 peerApiServerTimeout: 5s peerDialTimeout: 5s peerRequestTimeout: 5s peerUpdateInterval: 15mwhere:
-
spec.safeTimeToAssumeNodeRebootedSecondsdefines the time in seconds to wait before assuming the node has rebooted. Set this value to the node reboot time plus 20% for faster recovery, or plus 40% for a more conservative approach.
-
5.9.4. Capacity planning for VM failover リンクのコピーリンクがクリップボードにコピーされました!
Plan node capacity to ensure your cluster has enough resources to host VMs that migrate from failed nodes.
When a node fails and you have enabled remediation, VMs automatically migrate to other available nodes in the cluster. Monitor the following resources on your cluster to ensure adequate capacity for VM failover:
- VM count per node
- Available CPU
- Available memory
- Available disk
- Available network bandwidth
Check the current resource use of your nodes:
$ oc adm top nodes
The number of VMs that a node can host depends on the maxPods value set in the kubelet configuration:
kubeletConfig:
maxPods: 250
5.10. Configuring certificate rotation リンクのコピーリンクがクリップボードにコピーされました!
Configure certificate rotation parameters to replace existing certificates.
5.10.1. Configure certificate rotation リンクのコピーリンクがクリップボードにコピーされました!
If you did not configure certificate rotation during OpenShift Virtualization installation in the web console, you can use the HyperConverged custom resource (CR) to apply the configuration after installation.
Prerequisites
-
You have installed the OpenShift CLI (
oc).
Procedure
Open the
HyperConvergedCR by running the following command:$ oc edit hco kubevirt-hyperconverged -n openshift-cnvEdit the
spec.security.certConfigfields as shown in the following example. To avoid overloading the system, ensure that all values are greater than or equal to 10 minutes. Express all values as strings that comply with the golangParseDurationformat.apiVersion: hco.kubevirt.io/v1 kind: HyperConverged metadata: name: kubevirt-hyperconverged namespace: openshift-cnv spec: security: certConfig: ca: duration: 48h0m0s renewBefore: 24h0m0s server: duration: 24h0m0s renewBefore: 12h0m0s-
ca.renewBefore: Set to a value less than or equal to the value ofca.duration. -
server.duration: Set to a value less than or equal to the value ofca.duration. -
server.renewBefore; Set to a value less than or equal to the value ofserver.duration.
-
Apply updates to the
HyperConvergedCR by running the following command:$ oc apply -f <filename>.yamlFor example:
$ oc apply -f kubevirt-hyperconverged.yaml
5.10.2. Troubleshoot certificate rotation parameters リンクのコピーリンクがクリップボードにコピーされました!
Deleting one or more certConfig values in the HyperConverged custom resource (CR) causes the certConfig values to revert to the default values.
If the default values conflict with one of the following conditions, you receive an error message instead:
-
The value of
ca.renewBeforemust be less than or equal to the value ofca.duration. -
The value of
server.durationmust be less than or equal to the value ofca.duration. -
The value of
server.renewBeforemust be less than or equal to the value ofserver.duration.
For example, if you remove the server.duration value, the default value of 24h0m0s is greater than the value of ca.duration, which conflicts with the specified conditions:
apiVersion: hco.kubevirt.io/v1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
namespace: openshift-cnv
spec:
# ...
security:
certConfig:
ca:
duration: 4h0m0s
renewBefore: 1h0m0s
server:
duration: 4h0m0s
renewBefore: 4h0m0s
# ...
This results in the following error message:
error: hyperconvergeds.hco.kubevirt.io "kubevirt-hyperconverged" could not be patched: admission webhook "validate-hco.kubevirt.io" denied the request: spec.certConfig: ca.duration is smaller than server.duration
The error message only mentions the first conflict. Review all certConfig values before you proceed.
5.11. Configuring KubeVirt Redfish for VM management リンクのコピーリンクがクリップボードにコピーされました!
KubeVirt Redfish exposes OpenShift Virtualization virtual machines (VMs) through a Redfish-compatible API. This enables external tools and orchestration systems to manage VM power states, query inventory, and attach virtual media using the industry-standard Redfish protocol.
Use KubeVirt Redfish when you need programmatic control over VMs using Redfish, such as deploying virtualized control planes or automating VM lifecycle management.
5.11.1. KubeVirt Redfish API for VM management リンクのコピーリンクがクリップボードにコピーされました!
KubeVirt Redfish is a Redfish-compatible API that exposes virtual machines (VMs) managed by OpenShift Virtualization on OpenShift Container Platform.
You can use the same Redfish automation patterns you use for physical baseboard management controllers (BMCs) to manage VM power and inventory. The primary use case is deploying virtualized control plane clusters, where the control plane nodes run as VMs on an existing OpenShift Virtualization cluster.
5.11.2. KubeVirt Redfish architecture リンクのコピーリンクがクリップボードにコピーされました!
KubeVirt Redfish is deployed on the hosting cluster as a Deployment resource and is exposed using Service and Route resources. KubeVirt Redfish connects to the cluster API to list and control the KubeVirt VMs you expose through configuration.
Requests arrive at the KubeVirt Redfish endpoint, which is exposed as an OpenShift Container Platform Route. KubeVirt Redfish then translates supported Redfish operations into KubeVirt API calls to manage VM power state, inventory, and virtual media.
5.11.3. KubeVirt Redfish compared to physical BMC Redfish リンクのコピーリンクがクリップボードにコピーされました!
Redfish is commonly used with physical baseboard management controllers (BMCs) for bare metal deployments, where it manages hardware power state, boot configuration, and provisioning.
KubeVirt Redfish is different in some of the following ways:
- It targets VMs managed by OpenShift Virtualization, not physical servers.
- It runs as a service on your cluster, not on hardware BMCs.
- You can use it for virtualized control plane deployments where physical BMC Redfish supports bare metal deployments.
The two are complementary and can be used together in environments with mixed physical and virtual nodes.
5.11.4. Install KubeVirt Redfish リンクのコピーリンクがクリップボードにコピーされました!
Install KubeVirt Redfish on your OpenShift Virtualization cluster by applying a series of custom resources (CRs). These CRs create the namespace, permissions, configuration, and deployment required to expose VMs through the Redfish API.
Prerequisites
- You have a OpenShift Container Platform cluster with OpenShift Virtualization installed.
-
You installed the OpenShift CLI (
oc). -
You logged in to OpenShift Container Platform as a user with
cluster-adminprivileges.
Procedure
Create the
NamespaceCR for KubeVirt Redfish by creating a YAML file with content such as the following example:apiVersion: v1 kind: Namespace metadata: name: kubevirt-redfish labels: app.kubernetes.io/name: kubevirt-redfishApply the resource by running the following command:
$ oc apply -f namespace.yamlCreate the
ServiceAccountCR by creating a YAML file with content such as the following example:apiVersion: v1 kind: ServiceAccount metadata: name: kubevirt-redfish namespace: kubevirt-redfish labels: app.kubernetes.io/name: kubevirt-redfish app.kubernetes.io/component: rbacApply the resource by running the following command:
$ oc apply -f serviceaccount.yamlCreate the
ClusterRoleCR with required permissions by creating a YAML file with content such as the following example:apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: kubevirt-redfish-role labels: app.kubernetes.io/name: kubevirt-redfish app.kubernetes.io/component: rbac rules: - apiGroups: ["kubevirt.io"] resources: ["virtualmachines", "virtualmachineinstances"] verbs: ["get", "list", "watch", "update", "patch"] - apiGroups: ["kubevirt.io"] resources: ["virtualmachines/status", "virtualmachineinstances/status"] verbs: ["get", "list", "watch", "patch"] - apiGroups: ["kubevirt.io"] resources: ["virtualmachines/restart", "virtualmachines/start", "virtualmachines/stop"] verbs: ["create"] - apiGroups: ["subresources.kubevirt.io"] resources: ["virtualmachineinstances/pause", "virtualmachineinstances/unpause"] verbs: ["create", "update"] - apiGroups: [""] resources: ["pods", "services", "configmaps", "secrets"] verbs: ["get", "list", "watch", "create", "update", "delete"] - apiGroups: [""] resources: ["namespaces"] verbs: ["get", "list"] - apiGroups: ["cdi.kubevirt.io"] resources: ["datavolumes", "volumeimportsources"] verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] - apiGroups: [""] resources: ["persistentvolumeclaims"] verbs: ["get", "list", "create", "update", "patch", "delete", "watch"] - apiGroups: ["storage.k8s.io"] resources: ["storageclasses"] verbs: ["get", "list"]Apply the resource by running the following command:
$ oc apply -f clusterrole.yamlCreate the
ClusterRoleBindingCR by creating a YAML file with content such as the following example:apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: kubevirt-redfish-binding labels: app.kubernetes.io/name: kubevirt-redfish app.kubernetes.io/component: rbac roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: kubevirt-redfish-role subjects: - kind: ServiceAccount name: kubevirt-redfish namespace: kubevirt-redfishApply the resource by running the following command:
$ oc apply -f clusterrolebinding.yamlCreate a
SecretCR to enable the Redfish API to manage specific VMs:Generate a
bcrypthashed password for the Redfish API by running the following command in a Linux terminal:$ htpasswd -nbB "" '<password>' | cut -d: -f2<password>is the password you want to use for the Redfish API.The output is a
bcrypthashed password beginning with$2a$,$2b$, or$2y$.NoteIn earlier Technology Preview releases, plain text passwords were used. Use
bcrypthashed passwords for improved security.
Create the
SecretCR containing the configuration with content such as the following example. Edit theconfig.yamlsection to match your environment:apiVersion: v1 kind: Secret metadata: name: kubevirt-redfish-secret namespace: kubevirt-redfish labels: app.kubernetes.io/name: kubevirt-redfish app.kubernetes.io/component: config type: Opaque stringData: config.yaml: | server: host: "0.0.0.0" port: 8443 tls: enabled: false system_id_convention: "enhanced" chassis: - name: "<chassis_name>" namespace: "<vm_namespace>" service_account: "kubevirt-redfish" vm_selector: labels: redfish-enabled: "true" authentication: users: - username: "admin" password: hash: "<bcrypt_password>" chassis: ["<chassis_name>"] datavolume: storage_class: "<storage_class>" storage_size: "3Gi"where:
system_id_convention-
Specifies the format for Redfish system IDs. The recommended setting is
enhancedto use<namespace>.<vm-name>format. Thelegacysetting uses<vm-name>only. chassis-
Specifies the namespaces where VMs are deployed. Replace
<chassis_name>with a name for this chassis configuration and<vm_namespace>with the namespace containing your VMs. Thevm_selectorlabels identify which VMs in the namespace are exposed through Redfish. Only VMs with matching labels are visible. You can configure multiple chassis entries to expose different subsets of VMs in the same namespace, each with different authentication users. authentication-
Specifies the username and password required to validate requests to the Redfish API. Replace
<bcrypt_password>with thebcrypthashed password that you generated. datavolume-
Specifies storage for virtual media operations. KubeVirt Redfish uses this storage to create a data volume, download the installation ISO into that volume, and attach the volume to the VM as virtual media. Replace
<storage_class>with a storage class that points to a shared storage location accessible from all nodes in the hosting cluster. Do not use a node-local storage class such as LVM Storage for this volume. For more information about storage options, see Storage requirements in "Prerequisites for virtualized control planes".
Apply the resource by running the following command:
$ oc apply -f secret.yamlWarningThe credentials defined in this
SecretCR enable full management control over the VMs exposed through KubeVirt Redfish, independently of any OpenShift Container Platform privileges.Create the
DeploymentCR by creating a YAML file with content such as the following example:apiVersion: apps/v1 kind: Deployment metadata: name: kubevirt-redfish namespace: kubevirt-redfish labels: app.kubernetes.io/name: kubevirt-redfish app.kubernetes.io/component: server spec: replicas: 1 selector: matchLabels: app.kubernetes.io/name: kubevirt-redfish app.kubernetes.io/component: server template: metadata: labels: app.kubernetes.io/name: kubevirt-redfish app.kubernetes.io/component: server spec: serviceAccountName: kubevirt-redfish securityContext: runAsNonRoot: true containers: - name: kubevirt-redfish image: registry.redhat.io/container-native-virtualization/kubevirt-redfish-rhel9:v5.0 imagePullPolicy: Always ports: - name: http containerPort: 8443 protocol: TCP env: - name: CONFIG_PATH value: "/app/config/config.yaml" - name: LOG_LEVEL value: "info" resources: requests: memory: "512Mi" cpu: "100m" limits: memory: "2Gi" cpu: "500m" livenessProbe: httpGet: path: /redfish/v1/ port: 8443 scheme: HTTP initialDelaySeconds: 30 periodSeconds: 10 readinessProbe: httpGet: path: /redfish/v1/ port: 8443 scheme: HTTP initialDelaySeconds: 5 periodSeconds: 5 securityContext: runAsNonRoot: true allowPrivilegeEscalation: false capabilities: drop: - ALL volumeMounts: - name: config-volume mountPath: /app/config readOnly: true volumes: - name: config-volume secret: secretName: kubevirt-redfish-secretwhere:
-
The
imagefield specifies the KubeVirt Redfish container image.
-
The
Apply the resource by running the following command:
$ oc apply -f deployment.yamlCreate the
ServiceCR by creating a YAML file with content such as the following example:apiVersion: v1 kind: Service metadata: name: kubevirt-redfish namespace: kubevirt-redfish labels: app.kubernetes.io/name: kubevirt-redfish app.kubernetes.io/component: server spec: type: ClusterIP ports: - name: http port: 8443 targetPort: 8443 protocol: TCP selector: app.kubernetes.io/name: kubevirt-redfish app.kubernetes.io/component: serverApply the resource by running the following command:
$ oc apply -f service.yamlCreate the
RouteCR to expose the Redfish API externally by creating a YAML file with content such as the following example:apiVersion: route.openshift.io/v1 kind: Route metadata: name: kubevirt-redfish namespace: kubevirt-redfish labels: app.kubernetes.io/name: kubevirt-redfish app.kubernetes.io/component: server spec: port: targetPort: http to: kind: Service name: kubevirt-redfish weight: 100 tls: termination: edge insecureEdgeTerminationPolicy: RedirectApply the resource by running the following command:
$ oc apply -f route.yaml
Verification
Verify that the pods are running by running the following command:
$ oc get pods -n kubevirt-redfishExample output
NAME READY STATUS RESTARTS AGE kubevirt-redfish-587cd94988-xthml 1/1 Running 0 2mGet the route hostname by running the following command:
$ oc get route kubevirt-redfish -n kubevirt-redfish -o jsonpath='{.spec.host}'Test the Redfish endpoint by running the following command:
$ curl -sk -u "admin:<password>" https://<route_hostname>/redfish/v1/A successful response returns JSON with the Redfish service root:
{ "@odata.id": "/redfish/v1", "@odata.type": "#ServiceRoot.v1_0_0.ServiceRoot", "Id": "RootService", "Name": "Root Service", "Systems": { "@odata.id": "/redfish/v1/Systems" } }
5.11.5. Supported Redfish API endpoints リンクのコピーリンクがクリップボードにコピーされました!
KubeVirt Redfish implements a subset of the Redfish standard for managing virtual machines. The following table lists the supported API endpoints.
Access these endpoints using the full URL format https://<route_hostname>/<endpoint_path>, where <route_hostname> is the KubeVirt Redfish Route hostname.
In endpoint paths, {system_id} refers to the VM identifier. With the enhanced system ID convention, this is <namespace>.<vm-name>. With the legacy convention, this is <vm-name> only.
| Method | Endpoint | Description |
|---|---|---|
| GET |
| Service root. Returns available resource collections. |
| GET |
| List all VMs exposed as Redfish systems. |
| GET |
| Get details for a specific VM, including power state and boot settings. |
| POST |
|
Power operations. Supported |
| GET |
| Get VirtualMedia status for the VM’s virtual CD drive. |
| POST |
|
Attach an ISO image to the VM. Requires |
| POST |
| Detach the ISO image from the VM. |
| PATCH |
|
Modify boot settings. Set |