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-admin permissions.

Procedure

  1. 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-automation
  2. Determine the pull URL for the kubevirt-api-lifecycle image 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'
  3. Deploy Kubevirt-Api-Lifecycle-Automation by 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-automation

    where:

    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_GLOB value with your own pattern.
    RESTART_REQUIRED
    Specifies whether VMs should be restarted after the machine type is updated. If the RESTART_REQUIRED environment variable is set to true, VMs are restarted after the machine type is updated. If you do not want VMs to be restarted, set this value to false.
    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.
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る