9.8.8. Updating multiple virtual machines
You can use the command line interface (CLI) to update multiple virtual machines (VMs) at the same time.
Prerequisites
-
You installed the OpenShift CLI (
oc). -
You have access to the OpenShift Container Platform cluster, and you have
cluster-adminpermissions.
Procedure
Create a privileged service account by running the following commands:
$ oc adm new-project kubevirt-api-lifecycle-automation$ oc create sa kubevirt-api-lifecycle-automation -n kubevirt-api-lifecycle-automation$ oc create clusterrolebinding kubevirt-api-lifecycle-automation --clusterrole=cluster-admin --serviceaccount=kubevirt-api-lifecycle-automation:kubevirt-api-lifecycle-automationDetermine the pull URL for the
kubevirt-api-lifecycleimage by running the following command:$ oc get csv -n openshift-cnv -l=operators.coreos.com/kubevirt-hyperconverged.openshift-cnv -ojson | jq '.items[0].spec.relatedImages[] | select(.name|test(".*kubevirt-api-lifecycle-automation.*")) | .image'Deploy
Kubevirt-Api-Lifecycle-Automationby creating a job object as shown in the following example:apiVersion: batch/v1 kind: Job metadata: name: kubevirt-api-lifecycle-automation namespace: kubevirt-api-lifecycle-automation spec: template: spec: containers: - name: kubevirt-api-lifecycle-automation image: quay.io/openshift-virtualization/kubevirt-api-lifecycle-automation:v4.21 imagePullPolicy: Always env: - name: MACHINE_TYPE_GLOB value: smth-glob9.10.0 - name: RESTART_REQUIRED value: "true" - name: NAMESPACE value: "default" - name: LABEL_SELECTOR value: my-vm securityContext: allowPrivilegeEscalation: false capabilities: drop: - ALL privileged: false runAsNonRoot: true seccompProfile: type: RuntimeDefault restartPolicy: Never serviceAccountName: kubevirt-api-lifecycle-automationwhere:
quay.io/openshift-virtualization/kubevirt-api-lifecycle-automation:v4.21- Specifies the pull URL for your image. Replace the image value in this example with your pull URL for the image.
MACHINE_TYPE_GLOB-
Specifies the pattern that is used to detect deprecated machine types that need to be upgraded. Replace the
MACHINE_TYPE_GLOBvalue with your own pattern. RESTART_REQUIRED-
Specifies whether VMs should be restarted after the machine type is updated. If the
RESTART_REQUIREDenvironment variable is set totrue, VMs are restarted after the machine type is updated. If you do not want VMs to be restarted, set this value tofalse. NAMESPACE- Specifies the namespace to look for VMs in. Leave the parameter empty for the job to go over all namespaces in the cluster.
LABEL_SELECTOR- Specifies which VMs receive the job action. If you want the job to go over all VMs in the cluster, do not assign a value to the parameter.
9.8.8.1. Performing bulk actions on virtual machines リンクのコピーリンクがクリップボードにコピーされました!
You can perform bulk actions on multiple virtual machines (VMs) simultaneously by using the VirtualMachines list view in the web console. This allows you to efficiently manage a group of VMs with minimal manual effort.
Available bulk actions:
- Label VMs - Add, edit, or remove labels that are applied across selected VMs.
- Delete VMs - Select multiple VMs to delete. The confirmation dialog displays the number of VMs selected for deletion.
- Move VMs to folder - Move selected VMs to a folder. All VMs must belong to the same namespace.
- LiveMigration - Perform live migration of multiple selected VMs. The confirmation dialog displays the number of VMs selected for migration. The target node is chosen automatically; there is no option of specifying it.
- Take snapshot - Take snapshots of multiple VMs. The Take snapshots dialog allows you to enter a suffix for the names of the resulting snapshots.