1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/virt-updating-multiple-vms.adoc

97 lines
3.6 KiB
Plaintext

// Module included in the following assemblies:
//
// * virt/virtual_machines/virt-edit-vms.adoc
:_mod-docs-content-type: PROCEDURE
[id="virt-updating-multiple-vms_{context}"]
= Updating multiple virtual machines
[role="_abstract"]
You can use the command line interface (CLI) to update multiple virtual machines (VMs) at the same time.
.Prerequisites
* You installed the `oc` CLI.
* You have access to the {product-title} cluster, and you have `cluster-admin` permissions.
.Procedure
. Create a privileged service account by running the following commands:
+
[source,terminal]
----
$ oc adm new-project kubevirt-api-lifecycle-automation
----
+
[source,terminal]
----
$ oc create sa kubevirt-api-lifecycle-automation -n kubevirt-api-lifecycle-automation
----
+
[source,terminal]
----
$ oc create clusterrolebinding kubevirt-api-lifecycle-automation --clusterrole=cluster-admin --serviceaccount=kubevirt-api-lifecycle-automation:kubevirt-api-lifecycle-automation
----
. Determine the pull URL for the `kubevirt-api-lifecycle` image by running the following command:
+
[source,terminal]
----
$ 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-Automation` by creating a job object as shown in the following example:
+
[source,yaml]
----
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 <1>
imagePullPolicy: Always
env:
- name: MACHINE_TYPE_GLOB <2>
value: smth-glob9.10.0
- name: RESTART_REQUIRED <3>
value: "true"
- name: NAMESPACE <4>
value: "default"
- name: LABEL_SELECTOR <5>
value: my-vm
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
restartPolicy: Never
serviceAccountName: kubevirt-api-lifecycle-automation
----
<1> Replace the image value with your pull URL for the image.
<2> Replace the `MACHINE_TYPE_GLOB` value with your own pattern. This pattern is used to detect deprecated machine types that need to be upgraded.
<3> If the `RESTART_REQUIRED` emvironment variable is set to `true`, VMs are restarted after the machine type is updated. If you do not want VMs to be restarted, set the value to `false`.
<4> The `namespace` environment value indicates the namespace to look for VMs in. Leave the parameter empty for the job to go over all namespaces in the cluster.
<5> You can use the `LABEL_SELECTOR` environment variable to select VMs that 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.
[id="virt-performing-actions-on-multiple-virtual-machines_{context}"]
== 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.