Skip to content

Commit 757429b

Browse files
authored
Merge pull request #91316 from sbeskin-redhat/CNV_20188_mass_machine_type_change_procedure
CNV-20188: Mass machine type change procedure
2 parents ce1a772 + fe7615f commit 757429b

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/virtual_machines/virt-edit-vms.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="virt-updating-multiple-vms_{context}"]
7+
= Updating multiple virtual machines
8+
9+
You can use the command line interface (CLI) to update multiple virtual machines (VMs) at the same time.
10+
11+
.Prerequisites
12+
13+
* You installed the `oc` CLI.
14+
* You have access to the {product-title} cluster, and you have `cluster-admin` permissions.
15+
16+
.Procedure
17+
18+
. Create a privileged service account by running the following commands:
19+
+
20+
[source,terminal]
21+
----
22+
$ oc adm new-project kubevirt-api-lifecycle-automation
23+
----
24+
+
25+
[source,terminal]
26+
----
27+
$ oc create sa kubevirt-api-lifecycle-automation -n kubevirt-api-lifecycle-automation
28+
----
29+
+
30+
[source,terminal]
31+
----
32+
$ oc create clusterrolebinding kubevirt-api-lifecycle-automation --clusterrole=cluster-admin --serviceaccount=kubevirt-api-lifecycle-automation:kubevirt-api-lifecycle-automation
33+
----
34+
35+
. Determine the pull URL for the `kubevirt-api-lifecycle` image by running the following command:
36+
+
37+
[source,terminal]
38+
----
39+
$ 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'
40+
----
41+
42+
. Deploy `Kubevirt-Api-Lifecycle-Automation` by creating a job object as shown in the following example:
43+
+
44+
[source,yaml]
45+
----
46+
apiVersion: batch/v1
47+
kind: Job
48+
metadata:
49+
name: kubevirt-api-lifecycle-automation
50+
namespace: kubevirt-api-lifecycle-automation
51+
spec:
52+
template:
53+
spec:
54+
containers:
55+
- name: kubevirt-api-lifecycle-automation
56+
image: quay.io/openshift-virtualization/kubevirt-api-lifecycle-automation:v4.19 <1>
57+
imagePullPolicy: Always
58+
env:
59+
- name: MACHINE_TYPE_GLOB <2>
60+
value: smth-glob9.10.0
61+
- name: RESTART_REQUIRED <3>
62+
value: "true"
63+
- name: NAMESPACE <4>
64+
value: "default"
65+
- name: LABEL_SELECTOR <5>
66+
value: my-vm
67+
securityContext:
68+
allowPrivilegeEscalation: false
69+
capabilities:
70+
drop:
71+
- ALL
72+
privileged: false
73+
runAsNonRoot: true
74+
seccompProfile:
75+
type: RuntimeDefault
76+
restartPolicy: Never
77+
serviceAccountName: kubevirt-api-lifecycle-automation
78+
----
79+
80+
<1> Replace the image value with your pull URL for the image.
81+
<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.
82+
<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`.
83+
<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.
84+
<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.
85+
86+
87+

virt/managing_vms/virt-edit-vms.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ include::modules/virt-mounting-windows-driver-disk-on-vm.adoc[leveloffset=+1]
3030

3131
include::modules/virt-adding-secret-configmap-service-account-to-vm.adoc[leveloffset=+1]
3232

33+
include::modules/virt-updating-multiple-vms.adoc[leveloffset=+1]
34+
3335
[discrete]
3436
[id="additional-resources-configmaps"]
3537
[role="_additional-resources"]

0 commit comments

Comments
 (0)