|
1 | 1 | # VMware vSphere |
2 | 2 |
|
| 3 | +## Supported versions |
| 4 | + |
| 5 | +* 6.5 |
| 6 | +* 6.7 |
| 7 | + |
| 8 | +## Template VMs preparation |
| 9 | + |
3 | 10 | To use the machine-controller to create machines on VMWare vsphere, you must first |
4 | | -create a template. |
| 11 | +create a VM to be used as a template. |
| 12 | + |
| 13 | +*Note that:* |
| 14 | +`template VMs` in this document refers to regular VMs and not |
| 15 | +[VM Templates][vm_templates] according to vSphere terminology. |
| 16 | +The difference is quite subtle, but VM Templates are not supported yet by |
| 17 | +`machine controller`. |
5 | 18 |
|
6 | | -Ubuntu & CoreOS: |
| 19 | +### Create template VM from OVA |
7 | 20 |
|
8 | | -1. Go into the VSphere WebUI, select your datacenter, right click onto it and choose "Deploy OVF Template" |
9 | | -2. Fill in the "URL" field with the appropriate url: |
10 | | - * Ubuntu: `https://cloud-images.ubuntu.com/releases/18.04/release/ubuntu-18.04-server-cloudimg-amd64.ova` |
11 | | - * Container Linux: `https://stable.release.core-os.net/amd64-usr/current/coreos_production_vmware_ova.ova` |
| 21 | +To see where to locate the OVAs go to the OS specific section. |
| 22 | + |
| 23 | +#### WebUI procedure |
| 24 | + |
| 25 | +1. Go into the vSphere WebUI, select your datacenter, right click onto it and choose "Deploy OVF Template" |
| 26 | +2. Fill in the "URL" field with the appropriate url pointing to the `OVA` file |
12 | 27 | 3. Click through the dialog until "Select storage" |
13 | 28 | 4. Select the same storage you want to use for your machines |
14 | 29 | 5. Select the same network you want to use for your machines |
15 | 30 | 6. Leave everyhting in the "Customize Template" and "Ready to complete" dialog as it is |
16 | 31 | 7. Wait until the VM got fully imported and the "Snapshots" => "Create Snapshot" button is not grayed out anymore |
17 | 32 |
|
18 | | -CentOS: |
| 33 | +#### Command-line procedure |
| 34 | + |
| 35 | +Prerequisites: |
| 36 | + |
| 37 | +* [GOVC](https://github.com/vmware/govmomi/tree/master/govc): tested on version 0.22.1 |
| 38 | +* [jq](https://stedolan.github.io/jq/) |
| 39 | + |
| 40 | +Procedure: |
| 41 | + |
| 42 | +1. Download the `OVA` for the targeted OS. |
| 43 | + |
| 44 | + ``` |
| 45 | + curl -sL "${OVA_URL}" -O . |
| 46 | + ``` |
| 47 | +
|
| 48 | +2. Extract the specs from the `OVA`: |
| 49 | +
|
| 50 | + ``` |
| 51 | + govc import.spec $(basename "${OVA_URL}") | jq -r > options.json |
| 52 | + ``` |
| 53 | +
|
| 54 | +3. Edit the `options.json` file with your text editor of choice. |
| 55 | +
|
| 56 | + * Edit the `NetworkMapping` to point to the correct network. |
| 57 | + * Make sure that `PowerOn` is set to `false`. |
| 58 | + * Make sure that `MarkAsTemplate` is set to `false`. |
| 59 | + * Verify the other properties and customize according to your needs. |
| 60 | + e.g. |
| 61 | +
|
| 62 | + ```json |
| 63 | + { |
| 64 | + "DiskProvisioning": "flat", |
| 65 | + "IPAllocationPolicy": "dhcpPolicy", |
| 66 | + "IPProtocol": "IPv4", |
| 67 | + "PropertyMapping": [ |
| 68 | + { |
| 69 | + "Key": "guestinfo.hostname", |
| 70 | + "Value": "" |
| 71 | + }, |
| 72 | + { |
| 73 | + "Key": "guestinfo.coreos.config.data", |
| 74 | + "Value": "" |
| 75 | + }, |
| 76 | + { |
| 77 | + "Key": "guestinfo.coreos.config.url", |
| 78 | + "Value": "" |
| 79 | + }, |
| 80 | + { |
| 81 | + "Key": "guestinfo.coreos.config.data.encoding", |
| 82 | + "Value": "" |
| 83 | + }, |
| 84 | + { |
| 85 | + "Key": "guestinfo.interface.0.name", |
| 86 | + "Value": "" |
| 87 | + }, |
| 88 | + { |
| 89 | + "Key": "guestinfo.interface.0.mac", |
| 90 | + "Value": "" |
| 91 | + }, |
| 92 | + { |
| 93 | + "Key": "guestinfo.interface.0.dhcp", |
| 94 | + "Value": "no" |
| 95 | + }, |
| 96 | + { |
| 97 | + "Key": "guestinfo.interface.0.role", |
| 98 | + "Value": "public" |
| 99 | + }, |
| 100 | + { |
| 101 | + "Key": "guestinfo.interface.0.ip.0.address", |
| 102 | + "Value": "" |
| 103 | + }, |
| 104 | + { |
| 105 | + "Key": "guestinfo.interface.0.route.0.gateway", |
| 106 | + "Value": "" |
| 107 | + }, |
| 108 | + { |
| 109 | + "Key": "guestinfo.interface.0.route.0.destination", |
| 110 | + "Value": "" |
| 111 | + }, |
| 112 | + { |
| 113 | + "Key": "guestinfo.dns.server.0", |
| 114 | + "Value": "" |
| 115 | + }, |
| 116 | + { |
| 117 | + "Key": "guestinfo.dns.server.1", |
| 118 | + "Value": "" |
| 119 | + } |
| 120 | + ], |
| 121 | + "NetworkMapping": [ |
| 122 | + { |
| 123 | + "Name": "VM Network", |
| 124 | + "Network": "Loodse Default" |
| 125 | + } |
| 126 | + ], |
| 127 | + "MarkAsTemplate": false, |
| 128 | + "PowerOn": false, |
| 129 | + "InjectOvfEnv": false, |
| 130 | + "WaitForIP": false, |
| 131 | + "Name": null |
| 132 | + } |
| 133 | + ``` |
| 134 | +
|
| 135 | +4. Create a VM from the `OVA`: |
| 136 | +
|
| 137 | + ``` |
| 138 | + govc import.ova -options=options.json $(basename "${OVA_URL}") |
| 139 | + ``` |
| 140 | +
|
| 141 | +### Create template VM from qcow2 |
| 142 | +
|
| 143 | +Prerequisites: |
| 144 | +
|
| 145 | +* vSphere (tested on version 6.7) |
| 146 | +* GOVC (tested on version 0.22.1) |
| 147 | +* qemu-img (tested on version 4.2.0) |
| 148 | +* curl or wget |
| 149 | +
|
| 150 | +Procedure: |
| 151 | +
|
| 152 | +1. Download the guest image in qcow2 format end export an environment variable |
| 153 | + whith the name of the file. |
| 154 | +
|
| 155 | + ``` |
| 156 | + # The URL below is just an example |
| 157 | + image_url="https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2" |
| 158 | + image_name="$(basename -- "${image_url}" | sed 's/.qcow2$//g')" |
| 159 | + curl -sL "${image_url}" -O . |
| 160 | + ``` |
| 161 | +
|
| 162 | +2. Convert it to vmdk e.g. |
| 163 | +
|
| 164 | + ``` |
| 165 | + qemu-img convert -O vmdk -o subformat=streamOptimized "./${image_name}.qcow2" "${image_name}.vmdk" |
| 166 | + ``` |
| 167 | +
|
| 168 | +3. Upload to vSphere using WebUI or GOVC: |
| 169 | +
|
| 170 | + Make sure to replace the parameters on the command below with the correct |
| 171 | + values specific to yout vSphere environment. |
| 172 | +
|
| 173 | + ``` |
| 174 | + govc import.vmdk -dc=dc-1 -pool=/dc-1/host/cl-1/Resources -ds=ds-1 "./${image_name}.vmdk" |
| 175 | + ``` |
| 176 | +
|
| 177 | +4. Inflate the created disk (see vmware [documentation][inflate_thin_virtual_disks] for more details) |
| 178 | +
|
| 179 | + ``` |
| 180 | + govc datastore.disk.inflate -dc dc-1 -ds ds-1 "${image_name}/${image_name}.vmdk" |
| 181 | + ``` |
| 182 | +
|
| 183 | +5. Create a new virtual machine using that image with vSphere WebUI. |
| 184 | +6. During the `Customize Hardware` step: |
| 185 | + 1. Remove the disk present by default |
| 186 | + 2. Click on `ADD NEW DEVICE`, select `Existing Hard Disk` and select the |
| 187 | + disk previously created. |
| 188 | +7. The vm is ready to be used by the `MachineController` by referencing its name in the field `.spec.template.spec.providerSpec.value.cloudProviderSpec.templateVMName` of the `MachineDeployment`. |
| 189 | +
|
| 190 | +### OS images |
| 191 | +
|
| 192 | +Information about supported OS versions can be found [here](./operating-system.md#supported-os-versions). |
| 193 | +
|
| 194 | +#### Ubuntu |
| 195 | +
|
| 196 | +Ubuntu OVA template can be foud at <https://cloud-images.ubuntu.com/releases/18.04/release/ubuntu-18.04-server-cloudimg-amd64.ova>. |
| 197 | +
|
| 198 | +Follow [OVA](#create-template-vm-from-ova) template VM creation guide. |
| 199 | +
|
| 200 | +#### CoreOS |
| 201 | +
|
| 202 | +CoreOS OVA template can be foud at <https://stable.release.core-os.net/amd64-usr/current/coreos_production_vmware_ova.ova>. |
| 203 | +
|
| 204 | +Follow [OVA](#create-template-vm-from-ova) template VM creation guide. |
| 205 | +
|
| 206 | +#### RHEL |
| 207 | +
|
| 208 | +Red Hat Enterprise Linux 8.x KVM Guest Image can be found at [Red Hat Customer Portal][rh_portal_rhel8]. |
| 209 | +
|
| 210 | +Follow [qcow2](#create-template-vm-from-qcow2) template VM creation guide. |
| 211 | +
|
| 212 | +#### CentOS |
| 213 | +
|
| 214 | +CentOS 7 image can be found at the following link: <https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2r>. |
| 215 | +
|
| 216 | +Follow [qcow2](#create-template-vm-from-qcow2) template VM creation guide. |
| 217 | +
|
| 218 | +## Provider configuration |
| 219 | +
|
| 220 | +VSphere provider accepts the following configuration parameters: |
| 221 | +
|
| 222 | +```yaml |
| 223 | +# Can also be set via the env var 'VSPHERE_USERNAME' on the machine-controller |
| 224 | +username: '<< VSPHERE_USERNAME >>' |
| 225 | +# Can also be set via the env var 'VSPHERE_ADDRESS' on the machine-controller |
| 226 | +# example: 'https://your-vcenter:8443'. '/sdk' gets appended automatically |
| 227 | +vsphereURL: '<< VSPHERE_ADDRESS >>' |
| 228 | +# Can also be set via the env var 'VSPHERE_PASSWORD' on the machine-controller |
| 229 | +password: "<< VSPHERE_PASSWORD >>" |
| 230 | +# datacenter name |
| 231 | +datacenter: datacenter1 |
| 232 | +# VM template name |
| 233 | +templateVMName: ubuntu-template |
| 234 | +# Optional. Sets the networks on the VM. If no network is specified, the template default will be used. |
| 235 | +vmNetName: network1 |
| 236 | +# Optional |
| 237 | +folder: folder1 |
| 238 | +cluster: cluster1 |
| 239 | +# either datastore or datastoreCluster have to be provided. |
| 240 | +datastore: datastore1 |
| 241 | +datastoreCluster: datastore-cluster1 |
| 242 | +# Can also be set via the env var 'VSPHERE_ALLOW_INSECURE' on the machine-controller |
| 243 | +allowInsecure: true |
| 244 | +# instance resources |
| 245 | +cpus: 2 |
| 246 | +memoryMB: 2048 |
| 247 | +# Optional: Resize the root disk to this size. Must be bigger than the existing size |
| 248 | +# Default is to leave the disk at the same size as the template |
| 249 | +diskSizeGB: 10 |
| 250 | +``` |
| 251 | + |
| 252 | +### Datastore and DatastoreCluster |
| 253 | + |
| 254 | +A `Datastore` is the basic unit of storage abstraction in VSphere storage (more details [here][datastore]). |
| 255 | + |
| 256 | +A `DatastoreCluster` (sometimes referred to as StoragePod) is a logical grouping of `Datastores`, it provides some resource management capabilities (more details [here][datastore_cluster]). |
| 257 | + |
| 258 | +VSphere provider configuration in a `MachineDeployment` should specify either a `Datastore` or a `DatastoreCluster`. If both are specified or if one of the two is missing the `MachineDeployment` validation will fail. |
| 259 | + |
| 260 | +*Note that* |
| 261 | +the `datastore` or `datastoreCluster` specified in the `MachineDeployment` will be only used for the placement of VM and disk files related to the VMs provisioned by the `machine controller`. They do not influence the placement of persistent volumes used by PODs, that only depends on the cloud configuration given to the k8s cloud provider running in control plane. |
19 | 262 |
|
20 | | -1. Download the CentOS cloud image to your local workstation from here: `https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2` |
21 | | -1. Convert it to vmdk: `qemu-img convert -f qcow2 -O vmdk CentOS-7-x86_64-GenericCloud.qcow2 CentOS-7-x86_64-GenericCloud.vmdk` |
22 | | -1. Upload it to a Datastore of your Vsphere installation |
23 | | -1. Create a new virtual machine that uses the uploaded vmdk as rootdisk |
| 263 | +[vm_templates]: https://docs.vmware.com/en/VMware-vSphere/6.7/com.vmware.vsphere.vm_admin.doc/GUID-F7BF0E6B-7C4F-4E46-8BBF-76229AEA7220.html?hWord=N4IghgNiBcIG4FsAEAXApggDhM6DOIAvkA |
| 264 | +[datastore]: https://docs.vmware.com/en/VMware-vSphere/6.7/com.vmware.vsphere.storage.doc/GUID-3CC7078E-9C30-402C-B2E1-2542BEE67E8F.html |
| 265 | +[datastore_cluster]: https://docs.vmware.com/en/VMware-vSphere/6.7/com.vmware.vsphere.resmgmt.doc/GUID-598DF695-107E-406B-9C95-0AF961FC227A.html |
| 266 | +[inflate_thin_virtual_disks]: https://docs.vmware.com/en/VMware-vSphere/6.7/com.vmware.vsphere.storage.doc/GUID-C371B88F-C407-4A69-8F3B-FA877D6955F8.html |
| 267 | +[rh_portal_rhel8]: https://access.redhat.com/downloads/content/479/ver=/rhel---8/8.1/x86_64/product-software |
0 commit comments