Skip to content

Commit 27fce7c

Browse files
author
Audrey Spaulding
committed
fix merge conflicts
1 parent 1de0f04 commit 27fce7c

8 files changed

+189
-11
lines changed

_topic_maps/_topic_map.yml

+2
Original file line numberDiff line numberDiff line change
@@ -4667,6 +4667,8 @@ Topics:
46674667
File: virt-edit-boot-order
46684668
- Name: Deleting virtual machines
46694669
File: virt-delete-vms
4670+
- Name: Enabling or disabling virtual machine delete protection
4671+
File: virt-enabling-disabling-vm-delete-protection
46704672
- Name: Exporting virtual machines
46714673
File: virt-exporting-vms
46724674
- Name: Managing virtual machine instances

modules/virt-delete-vm-web.adoc

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
// Module included in the following assemblies:
22
//
3-
// * virt/virtual_machines/virt-delete-vms.adoc
3+
// * virt/managing-vms/virt-delete-vms.adoc
44

55
:_mod-docs-content-type: PROCEDURE
66
[id="virt-delete-vm-web_{context}"]
77

88
= Deleting a virtual machine using the web console
99

10-
Deleting a virtual machine permanently removes it from the cluster.
10+
Deleting a virtual machine (VM) permanently removes it from the cluster.
11+
12+
If the VM is delete protected, the *Delete* action is disabled in the VM's *Actions* menu.
13+
14+
.Prequisite
15+
16+
* To delete the VM, you must first disable the VM's delete protection setting, if enabled.
1117

1218
.Procedure
1319

14-
. In the {product-title} console, click *Virtualization* -> *VirtualMachines* from the side menu.
20+
. From the {product-title} web console, choose your view:
21+
22+
* For a virtualization-focused view, select *Administrator* → *Virtualization* → *VirtualMachines*.
23+
24+
* For a general view, navigate to *Virtualization* → *VirtualMachines*.
1525

16-
. Click the Options menu {kebab} beside a virtual machine and select *Delete*.
26+
. Click the *Actions* menu {kebab} beside a VM and select *Delete*.
1727
+
18-
Alternatively, click the virtual machine name to open the *VirtualMachine details* page and click *Actions* -> *Delete*.
28+
Alternatively, click the VM's name to open the *VirtualMachine details* page and click *Actions* -> *Delete*.
1929

2030
. Optional: Select *With grace period* or clear *Delete disks*.
2131

22-
. Click *Delete* to permanently delete the virtual machine.
32+
. Click *Delete* to permanently delete the VM.

modules/virt-deleting-vms.adoc

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
// Module included in the following assemblies:
22
//
3-
// * virt/virtual_machines/virt-delete-vms.adoc
3+
// * virt/managing-vms/virt-delete-vms.adoc
44

55
:_mod-docs-content-type: PROCEDURE
66
[id="virt-deleting-vms_{context}"]
77

88
= Deleting a virtual machine by using the CLI
99

10-
You can delete a virtual machine by using the `oc` command-line interface (CLI). The `oc` client enables you to perform actions on multiple virtual machines.
10+
You can delete a virtual machine (VM) by using the `oc` command-line interface (CLI). The `oc` client enables you to perform actions on multiple VMs.
1111

1212
.Prerequisites
1313

14-
* Identify the name of the virtual machine that you want to delete.
14+
* To delete the VM, you must first disable the VM's delete protection setting, if enabled.
1515

1616
.Procedure
1717

18-
* Delete the virtual machine by running the following command:
18+
* Delete the VM by running the following command:
1919
+
2020
[source,terminal]
2121
----
@@ -28,3 +28,4 @@ This command only deletes a VM in the current project. Specify the
2828
`-n <project_name>` option if the VM you want to delete is in
2929
a different project or namespace.
3030
====
31+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/managing-vms/virt-enabling-disabling-vm-delete-protection.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="virt-enabling-disabling-vm-delete-protection-cli_{context}"]
7+
8+
= Enabling or disabling virtual machine delete protection by using the command line
9+
10+
To prevent the inadvertent deletion of a virtual machine (VM), you can enable virtual machine delete protection by using the command line. You can also disable delete protection for a VM.
11+
12+
By default, delete protection is not enabled for VMs. You must set the option for each individual VM.
13+
14+
.Prerequisites
15+
16+
* You have installed the {oc-first}.
17+
18+
.Procedure
19+
20+
* Enable delete protection for a VM by running the following command:
21+
+
22+
[source,terminal]
23+
----
24+
$ oc patch vm <vm_name> --type merge -p '{"metadata":{"labels":{"kubevirt.io/vm-delete-protection":"True"}}}' -n <namespace>
25+
----
26+
27+
* Disable delete protection for a VM by running the following command:
28+
+
29+
[source,terminal]
30+
----
31+
$ oc patch vm <vm_name> --type json -p '[{"op": "remove", "path": "/metadata/labels/kubevirt.io~1vm-delete-protection"}]' -n <namespace>
32+
----
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/managing-vms/virt-enabling-disabling-vm-delete-protection.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="virt-enabling-disabling-vm-delete-protection-web_{context}"]
7+
8+
= Enabling or disabling virtual machine delete protection by using the web console
9+
10+
To prevent the inadvertent deletion of a virtual machine (VM), you can enable virtual machine delete protection by using the {product-title} web console. You can also disable delete protection for a VM.
11+
12+
By default, delete protection is not enabled for VMs. You must set the option for each individual VM.
13+
14+
.Procedure
15+
16+
. From the {product-title} web console, choose your view:
17+
18+
* For a virtualization-focused view, select *Administrator* → *Virtualization* → *VirtualMachines*.
19+
20+
* For a general view, navigate to *Virtualization* → *VirtualMachines*.
21+
22+
. From the *VirtualMachines* list, select the VM whose delete protection you want to enable or disable.
23+
24+
. Click the *Configuration* tab.
25+
26+
. In the *VirtualMachines details*, choose to enable or disable the protection as follows:
27+
28+
* To enable the protection:
29+
.. Set the *Deletion protection* switch to *On*.
30+
.. Click *Enable* to confirm the protection.
31+
32+
* To disable the protection:
33+
.. Set the *Deletion protection* switch to *Off*.
34+
.. Click *Disable* to disable the protection.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/managing-vms/virt-enabling-disabling-vm-delete-protection.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="virt-removing-vm-delete-protection_{context}"]
7+
8+
= Removing the virtual machine delete protection option
9+
10+
When you enable delete protection on a virtual machine (VM), you ensure that the VM cannot be inadvertently deleted. You can also choose to disable the protection for a VM.
11+
12+
As a cluster administrator, you can choose not to make the VM delete protection option available. VMs with delete protection already enabled retain that setting; for any new VMs that are created, enabling the option is not allowed.
13+
14+
You can remove the delete protection option by establishing a validation admission policy for the cluster and then creating the necessary binding to use the policy in the cluster.
15+
16+
.Prerequisites
17+
18+
* You must have cluster administrator privileges.
19+
20+
.Procedure
21+
22+
. Create the validation admission policy, as shown in the following example:
23+
+
24+
.Example validation admission policy file
25+
[source,yaml]
26+
----
27+
apiVersion: admissionregistration.k8s.io/v1
28+
kind: ValidatingAdmissionPolicy
29+
metadata:
30+
name: "disable-vm-delete-protection"
31+
spec:
32+
failurePolicy: Fail
33+
matchConstraints:
34+
resourceRules:
35+
- apiGroups: ["kubevirt.io"]
36+
apiVersions: ["*"]
37+
operations: ["UPDATE", "CREATE"]
38+
resources: ["virtualmachines"]
39+
variables:
40+
- expression: string('kubevirt.io/vm-delete-protection')
41+
name: vmDeleteProtectionLabel
42+
validations:
43+
- expression: "!has(object.metadata.labels) || !object.metadata.labels.exists(label, label == variables.vmDeleteProtectionLabel) || has(oldObject.metadata.labels) && \
44+
oldObject.metadata.labels.exists(label, label == variables.vmDeleteProtectionLabel)"
45+
message: "Virtual Machine delete protection feature is disabled"
46+
----
47+
48+
. Apply the validation admission policy to the cluster:
49+
+
50+
[source,terminal]
51+
----
52+
$ oc apply -f disable-vm-delete-protection.yaml
53+
----
54+
55+
. Create the validation admission policy binding, as shown in the following example:
56+
+
57+
.Example validation admission policy binding file
58+
[source,yaml]
59+
----
60+
apiVersion: admissionregistration.k8s.io/v1
61+
kind: ValidatingAdmissionPolicyBinding
62+
metadata:
63+
name: "disable-vm-delete-protection-binding"
64+
spec:
65+
policyName: "disable-vm-delete-protection"
66+
validationActions: [Deny]
67+
matchResources:
68+
----
69+
70+
. Apply the validation admission policy binding to the cluster:
71+
+
72+
[source,terminal]
73+
----
74+
$ oc apply -f disable-vm-delete-protection-binding.yaml
75+
----

virt/managing_vms/virt-delete-vms.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include::_attributes/common-attributes.adoc[]
66

77
toc::[]
88

9-
You can delete a virtual machine from the web console or by using the `oc` command-line interface.
9+
You can delete a virtual machine by using the web console or the `oc` command line interface.
1010

1111
include::modules/virt-delete-vm-web.adoc[leveloffset=+1]
1212
include::modules/virt-deleting-vms.adoc[leveloffset=+1]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
[id="virt-enabling-disabling-vm-delete-protection"]
3+
= Enabling or disabling virtual machine delete protection
4+
include::_attributes/common-attributes.adoc[]
5+
:context: virt-enabling-disabling-vm-delete-protection
6+
7+
toc::[]
8+
9+
You can prevent the inadvertent deletion of a virtual machine (VM) by enabling delete protection for the VM. You can also disable delete protection for the VM.
10+
11+
You enable or disable delete protection from either the command line or the VM's *VirtualMachine details* page in the {product-title} web console. The option is disabled by default.
12+
13+
You can also choose to remove availability of the delete protection option for any VMs in a cluster you administer. In this case, VMs with the feature already enabled retain the protection, while the option is unavailable for any newly created VMs.
14+
15+
include::modules/virt-enabling-disabling-vm-delete-protection-web.adoc[leveloffset=+1]
16+
include::modules/virt-enabling-disabling-vm-delete-protection-cli.adoc[leveloffset=+1]
17+
include::modules/virt-removing-vm-delete-protection.adoc[leveloffset=+1]
18+
19+
[role="_additional-resources"]
20+
[id="additional-resources_{context}"]
21+
== Additional resources
22+
* xref:../../virt/managing_vms/virt-enabling-disabling-vm-delete-protection.adoc#virt-enabling-disabling-vm-delete-protection-web_virt-enabling-disabling-vm-delete-protection[Enabling or disabling virtual machine delete protection by using the web console]
23+
* xref:../../virt/managing_vms/virt-enabling-disabling-vm-delete-protection.adoc#virt-enabling-disabling-vm-delete-protection-cli_virt-enabling-disabling-vm-delete-protection[Enabling or disabling virtual machine delete protection by using the CLI]

0 commit comments

Comments
 (0)