Skip to content

Commit

Permalink
Add docs for CD-ROM and ISO VM deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dilyar85 committed Dec 26, 2024
1 parent b5d30b4 commit 842eae1
Show file tree
Hide file tree
Showing 3 changed files with 211 additions and 1 deletion.
40 changes: 39 additions & 1 deletion docs/concepts/workloads/vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The name of a VM must be a valid [DNS subdomain](https://kubernetes.io/docs/conc

### VM Image

The `VirtualMachineImage` is a namespace-scoped resource from which a VM's disk image(s) is/are derived. This is why the name of a `VirtualMachineImage` resource must be specified when creating a new VM. It is also possible to deploy a new VM with the cluster-scoped `ClusterVirtualMachineImage` resource. The following commands may be used to discover the available images:
The `VirtualMachineImage` is a namespace-scoped resource from which a VM's disk image(s) is/are derived. This is why the name of a `VirtualMachineImage` resource must be specified when creating a new VM from OVF. It is also possible to deploy a new VM with the cluster-scoped `ClusterVirtualMachineImage` resource. The following commands may be used to discover the available images:

=== "Get images for a namespace"

Expand Down Expand Up @@ -103,6 +103,10 @@ It is possible to update parts of an existing `VirtualMachine` resource. Some fi
| `spec.className` | The name of the `VirtualMachineClass` that supplies the VM's virtual hardware ||| _NA_ |
| `spec.powerState` | The VM's desired power state ||| _NA_ |
| `metadata.labels.topology.kubernetes.io/zone` | The desired availability zone in which to schedule the VM | x | x ||
| `spec.cdrom.name` | The name of the CD-ROM device to mount ISO in the VM | x || _NA_ |
| `spec.cdrom.image` | The reference to an ISO type `VirtualMachineImage` or `ClusterVirtualMachineImage` to mount in the VM | x || _NA_ |
| `spec.cdrom.connected` | The desired connection state of the CD-ROM device ||| _NA_ |
| `spec.cdrom.allowGuestControl` | Whether the guest OS is allowed to connect/disconnect the CD-ROM device ||| _NA_ |

Some of a VM's hardware resources are derived from the policies defined by your infrastructure administrator, others may be influenced directly by a user.

Expand Down Expand Up @@ -777,3 +781,37 @@ rockylinux_64Guest Rocky Linux (64-bit)
windows2022srvNext_64Guest Microsoft Windows Server 2025 (64-bit)
...
```

## CD-ROM

The `spec.cdrom` field may be used to mount one or more ISO images in a VM. Each entry in the `spec.cdrom` field must reference a unique `VirtualMachineImage` or `ClusterVirtualMachineImage` resource as backing. Multiple CD-ROM devices using the same backing image, regardless of image kind (namespace or cluster scope), are not allowed.

### CD-ROM Name

The `spec.cdrom[].name` field consists of at least two lowercase letters or digits of this CD-ROM device. It must be unique among all CD-ROM devices attached to the VM.

### CD-ROM Image

The `spec.cdrom[].image` field is the Kubernetes object reference to the ISO type `VirtualMachineImage` or `ClusterVirtualMachineImage` resource. The following commands may be used to discover the available ISO type images:

=== "Get ISO images for a namespace"

```shell
kubectl get -n <NAMESPACE> vmi -l image.vmoperator.vmware.com/type=ISO
```

=== "Get ISO images for a cluster"

```shell
kubectl get cvmi -l image.vmoperator.vmware.com/type=ISO
```

### CD-ROM Connection State

The `spec.cdrom[].connected` field controls the connection state of the CD-ROM device. When set to `true`, the device is added and connected to the VM, or updated to a connected state if already present but disconnected. When explicitly set to `false`, the device is added but remains disconnected from the VM, or updated to a disconnected state if already connected.

### CD-ROM Guest Control

The `spec.cdrom[].allowGuestControl` field controls the guest OS's ability to connect/disconnect the CD-ROM device. If set to `true` (default value), a web console connection may be used to connect/disconnect the CD-ROM device from within the guest OS.

For more information on the ISO VM workflow, please refer to the [Deploy VM from ISO](../tutorials/iso.md) tutorial.
9 changes: 9 additions & 0 deletions docs/tutorials/deploy-vm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ spec:
bootstrap: # (8)
cloudInit:
cloudConfig: {}
cdrom: # (9)
- name: cdrom1
image:
name: vmi-0a0044d7c690bcbea
kind: VirtualMachineImage
connected: true
allowGuestControl: true
```
1. :wave: The field `apiVersion` indicates the resource's schema, ex. `vmoperator.vmware.com`, and version, ex.`v1alpha2`.
Expand Down Expand Up @@ -68,6 +75,8 @@ spec:

8. :wave: The field `spec.bootstrap`, and the fields inside of it, are used to configure the VM's [bootstrap provider](#bootstrap-provider).

9. :wave: The field `spec.cdrom` is used to configure the VM's [CD-ROM](../workloads/vm.md#cdrom) devices to mount ISO images.

## Bootstrap Provider

There are a number of methods that may be used to bootstrap a virtual machine's (VM) guest operating system:
Expand Down
163 changes: 163 additions & 0 deletions docs/tutorials/deploy-vm/iso.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Deploy a VM with ISO

This tutorial describes the end-to-end workflow for importing an ISO image from a URL, deploying a VM from the ISO image, and installing the guest OS via VM's web console.

## Import ISO from URL

ISO images are usually imported by an infrastructure administrator into a Content Library that can be associated to a namespace or cluster. To check if there is any ISO images available in a namespace or cluster, the following commands may be used:

```shell
$ kubectl get -n <NAMESPACE> vmi -l image.vmoperator.vmware.com/type=ISO

$ kubectl get cvmi -l image.vmoperator.vmware.com/type=ISO
```

DevOps can also import ISO images from a URL using the image registry operator's [ContentLibraryItemImportRequest](https://github.com/vmware-tanzu/image-registry-operator-api/blob/main/api/v1alpha1/contentlibraryitemimportrequest_types.go) API. The following example demonstrates how to import an upstream Rocky Linux ISO image:

```yaml
apiVersion: imageregistry.vmware.com/v1alpha1
kind: ContentLibraryItemImportRequest
metadata:
name: rocky-dvd-iso
namespace: my-namespace
spec:
source:
url: https://download.rockylinux.org/pub/rocky/9/isos/x86_64/Rocky-9.5-x86_64-dvd.iso # (1)
sslCertificate: | # (2)
-----BEGIN CERTIFICATE-----
MIIFLzCCBBegAwIBAgISBGoStW8/uta8jDAR8ldbQDihMA0GCSqGSIb3DQEBCwUA
MDMxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQwwCgYDVQQD
EwNSMTEwHhcNMjQxMjA2MTE1MzAzWhcNMjUwMzA2MTE1MzAyWjAhMR8wHQYDVQQD
ExZtaXJyb3JzLnJvY2t5bGludXgub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
MIIBCgKCAQEA6EZ30U0n8CBlWl8jC3Zwasky+3SQDXmehkPLo0K0v7kHPE4g+NUa
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FzMO3adyo0pWOCnEoIcVqLwWk8Yw
DQYJKoZIhvcNAQELBQADggEBAKm1NbsCgzov+GYAZHkkOHcw6ypbTsg1126HIB6k
n4RKFDTpvj62YCZTkTSAKY7gHSMt18jNN7LWv344dxLSB+goA5QSMUNHrsURoRW3
Bh7n2j6rr6LSF2HhBvRBPUk8HI8OgvuBXP0looxVgfBwybCEwjCa6iTaqcwPcECz
8P5r+lRn2nj3aDFrQ/zYZjA28A2bIgjcedg/5q1FNwPZWzsQ/tK6wkDeENzLgs5x
y9AY7M6fnRUbYGYauLA50clZAmxG63oApiaOvNFn1oK3TSAHkk1mZ16ibupI0e2F
Ypmf48/C4TvbDkL8qGM0o8hDqzax8eEY4w6sWbV9U/HnzcM=
-----END CERTIFICATE-----
checksum: # (3)
value: ba60c3653640b5747610ddfb4d09520529bef2d1d83c1feb86b0c84dff31e04e
algorithm: SHA256
target:
item:
name: rocky-dvd-iso
type: ISO
library:
apiVersion: imageregistry.vmware.com/v1alpha1
kind: ContentLibrary
name: cl-bb87952414e9859e8 # (4)
```
1. :wave: The URL specifies an ISO file to be imported as a `VirtualMachineImage` resource.
2. :wave: A PEM encoded SSL Certificate for the endpoint specified by the above URL.
3. :wave: An optional field to verify the checksum algorithm and value for the file at the URL.
4. :wave: The name of the Kubernetes content library object associated with the namespace for importing the ISO image.

## Deploy VM from ISO

Once the ISO image is available, A VM can be deployed with CD-ROM configured to mount the ISO image and PVC attached to use as the VM's boot disk. The following example demonstrates creating a PVC as well as a VM from the ISO image:

```yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
namespace: my-namespace
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi # (1)
storageClassName: wcpglobal-storage-profile
---
apiVersion: vmoperator.vmware.com/v1alpha3
kind: VirtualMachine
metadata:
name: my-iso-vm
namespace: my-namespace
spec:
className: best-effort-small
storageClass: wcpglobal-storage-profile
guestID: vmwarePhoton64Guest # (2)
cdrom:
- name: cdrom1 # (3)
image:
kind: VirtualMachineImage # (4)
name: vmi-0a0044d7c690bcbea # (5)
connected: true # (6)
allowGuestControl: true # (7)
volumes:
- name: boot-disk
persistentVolumeClaim:
claimName: my-pvc # (8)
```

1. :wave: The `storage` field specifies the size of the VM's boot disk.
2. :wave: The `guestID` field is required to specify the [guest operating system identifier](https://dp-downloads.broadcom.com/api-content/apis/API_VWSA_001/8.0U3/html/ReferenceGuides/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html) when deploying a VM from an ISO image.
3. :wave: The `name` field must consist of at least two lowercase letters or digits and be unique among all CD-ROM devices attached to the VM.
4. :wave: The `image.kind` field specifies the type of the ISO image (either `VirtualMachineImage` or `ClusterVirtualMachineImage`).
5. :wave: The `image.name` field specifies the Kubernetes object name of the ISO type `VirtualMachineImage` or `ClusterVirtualMachineImage` resource.
6. :wave: The `connected` field indicates the desired connection state of the CD-ROM device (defaults to `true`).
7. :wave: The `allowGuestControl` field specifies whether a web console connection can manage the CD-ROM device's connection state (defaults to `true`).
8. :wave: The `claimName` field specifies the name of the PVC to be used as the VM's boot disk.

## Install Guest OS

Once the VM is deployed and powered on, the guest OS can be installed via the VM's web console. To access the web console, the following command may be used:

```shell
$ kubectl vsphere vm web-console -n <NAMESPACE> <VM_NAME>
```

Click on the URL generated by the command to access the web console. Depending on the OS type, it may require various configuration steps to complete the installation. For network configuration, run the following command in the cluster to assign an IP address manually to the VM's network interface:

```shell
$ kubectl get vm -n <NAMESPACE> <VM_NAME> -o jsonpath='{.status.network.config}'
```

The output will be similar to the following:

```json
{
"dns": {
"hostName": "<VM_NAME>",
"nameservers": [
"<NAMESERVER_IP_1>",
"<NAMESERVER_IP_2>"
]
},
"interfaces": [
{
"ip": {
"addresses": [
"<IP_ADDRESS>/<NETMASK>"
],
"gateway4": "<GATEWAY_IP>"
},
"name": "<INTERFACE_NAME>"
}
]
}
```

Complete the remaining configuration steps via the web console and reboot the VM after installation. Wait for the VM to power on with the IP address assigned. If no IP address appears, verify that VMware Tools (or an open-source equivalent) is installed and running on the VM.

0 comments on commit 842eae1

Please sign in to comment.