Skip to content

Commit ea01ca0

Browse files
authored
Move vSphere cloud provider and RHEL image preparation doc to dedicated file and improve it (#736)
1 parent 3028e6d commit ea01ca0

File tree

4 files changed

+271
-64
lines changed

4 files changed

+271
-64
lines changed

docs/cloud-provider.md

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -277,33 +277,4 @@ tags:
277277
278278
## vSphere
279279
280-
### machine.spec.providerConfig.cloudProviderSpec
281-
```yaml
282-
# Can also be set via the env var 'VSPHERE_USERNAME' on the machine-controller
283-
username: '<< VSPHERE_USERNAME >>'
284-
# Can also be set via the env var 'VSPHERE_ADDRESS' on the machine-controller
285-
# example: 'https://your-vcenter:8443'. '/sdk' gets appended automatically
286-
vsphereURL: '<< VSPHERE_ADDRESS >>'
287-
# Can also be set via the env var 'VSPHERE_PASSWORD' on the machine-controller
288-
password: "<< VSPHERE_PASSWORD >>"
289-
# datacenter name
290-
datacenter: datacenter1
291-
# VM template name
292-
templateVMName: ubuntu-template
293-
# Optional. Sets the networks on the VM. If no network is specified, the template default will be used.
294-
vmNetName: network1
295-
# Optional
296-
folder: folder1
297-
cluster: cluster1
298-
# either datastore or datastoreCluster have to be provided.
299-
datastore: datastore1
300-
datastoreCluster: datastore-cluster1
301-
# Can also be set via the env var 'VSPHERE_ALLOW_INSECURE' on the machine-controller
302-
allowInsecure: true
303-
# instance resources
304-
cpus: 2
305-
memoryMB: 2048
306-
# Optional: Resize the root disk to this size. Must be bigger than the existing size
307-
# Default is to leave the disk at the same size as the template
308-
diskSizeGB: 10
309-
```
280+
Refer to the [VSphere](./vsphere.md#provider-configuration) specific documentation.

docs/operating-system.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ Machine controller may work with other OS versions that are not listed in the ta
3434
| | Versions |
3535
|---|---|
3636
| CentOS | 7.4.x, 7.6.x, 7.7.x |
37-
| CoreOS | 1855.4.0, 2079.3.0, 2345.3.0 |
38-
| RHEL | 8.0 |
37+
| CoreOS | 1855.4.0, 2079.x.x, 2135.x.x, 2191.x.x, 2247.x.x, 2345.x.x |
38+
| RHEL | 8.0, 8.1 |
3939
| SLES | SLES 15 SP1 |
4040
| Ubuntu | 18.04 LTS |
4141

docs/rhel-custom-image.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# RedHat Enterprise Linux
22

3-
Cloud providers which are listed below, support using rhel as an operating system option:
3+
Cloud providers which are listed below, support using RHEL as an operating system option:
44

55
- AWS
66
- Azure
@@ -9,31 +9,31 @@ Cloud providers which are listed below, support using rhel as an operating syste
99
- Openstack
1010
- vSphere
1111

12-
#### AWS:
13-
For amazon web service cloud provider, First of all the RHEL gold image AMIs have to be enabled from the
14-
[RedHat Customer Portal](https://access.redhat.com/public-cloud/aws) (this requires a [cloud-provider subscription](https://access.redhat.com/public-cloud)).
15-
.Afterwards, new images will be added to the aws account under EC2-> Images-> AMIs-> Private Images. Once the images are available in the aws account,
16-
the image id for rhel(supported versions are mentioned [here](https://github.com/kubermatic/machine-controller/blob/master/docs/operating-system.md)) should be then added to the `MachineDeployment` spec to the field `ami`.
12+
#### AWS
13+
First of all the RHEL gold image AMIs have to be enabled from the [RedHat Customer Portal](https://access.redhat.com/public-cloud/aws) (this requires a [cloud-provider subscription](https://access.redhat.com/public-cloud)).
14+
15+
Afterwards, new images will be added to the aws account under EC2-> Images-> AMIs-> Private Images.
16+
Once the images are available in the aws account, the image id for RHEL (supported versions are mentioned [here](./operating-system.md#supported-os-versions)) should be then added to the `MachineDeployment` spec to the field `ami`.
1717

1818
#### Azure
1919
RedHat provides images for Azure, [documentation](https://access.redhat.com/articles/uploading-rhel-image-to-azure) is available on RH customer portal.
20+
2021
The `MachineDeployment` field `.spec.template.spec.providerSpec.value.cloudProviderSpec.imageID` should reference the ID of the uploaded VM.
2122

2223
**Note:**
23-
Azure rhel images starting from 7.6.x don't support cloud-init as their documentation states [here](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/using-cloud-init#rhel).
24+
Azure RHEL images starting from 7.6.x don't support cloud-init as their documentation states [here](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/using-cloud-init#rhel).
2425
Thus, custom images can be used with a cloud-init pre-installed to solve this issue. Follow this [documentation](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cloudinit-prepare-custom-image)
2526
to prepare an image with cloud-init support.
2627

2728
#### GCE
2829
RedHat also provides Gold Access Image for GCE and those can be fetched just like aws and azure. The `MachineDeployment` field `.spec.template.spec.providerSpec.value.cloudProviderSpec.customImage` should reference the ID of the used image.
2930

3031
**Note:**
31-
Same as for Azure, rhel images in GCE don't support cloud-init. Thus, custom images can be used with a cloud-init pre-installed
32-
to solve this issue. Follow this [documentation](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/deploying_red_hat_enterprise_linux_8_on_public_cloud_platforms/assembly_deploying-a-rhel-image-as-a-compute-engine-instance-on-google-cloud-platform_deploying-a-virtual-machine-on-aws) to upload custom rhel
33-
images in order to use it for running rhel instances.
32+
RHEL images in GCE don't support cloud-init. Thus, custom images can be used with a cloud-init pre-installed
33+
to solve this issue. Follow this [documentation](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/deploying_red_hat_enterprise_linux_8_on_public_cloud_platforms/assembly_deploying-a-rhel-image-as-a-compute-engine-instance-on-google-cloud-platform_deploying-a-virtual-machine-on-aws) to upload custom RHEL images.
3434

3535
#### KubeVirt
36-
In order to create machines which run rhel as an operating system in KubeVirt cloud provider, the image should be available and fetched
36+
In order to create machines which run RHEL as an operating system in KubeVirt cloud provider, the image should be available and fetched
3737
via an endpoint. This endpoint should be then added to the `MachineDeployment` field `.spec.template.spec.providerSpec.value.cloudProviderSpec.sourceURL`. For more information about
3838
the supported images please refer to this documentation from KubeVirt CDI [here](https://kubevirt.io/2018/containerized-data-importer.html)
3939

@@ -42,13 +42,5 @@ Once RHEL images(e.g: Red Hat Enterprise Linux 8.x KVM Guest Image) is uploaded
4242
the `MachineDeployment` field `.spec.template.spec.providerSpec.value.cloudProviderSpec.image`.
4343

4444
#### vSphere
45-
To rhel os for vSphere instance, a template for the rhel machine should be created or a clone from a rhel machine. To upload rhel
46-
image to vSphere, follow these steps to create instances from a cloned machine:
47-
48-
- Download Red Hat Enterprise Linux 8.x KVM Guest Image from Red Hat Customer Portal.
49-
- The image has the format `qcow2` thus should be converted to `vmdk` by running the command: `qemu-img convert -f qcow2 rhel.qcow2 -O vmdk newRHEL.vmdk`
50-
- Upload the image to vSphere Datastore. Preferably use [`govc`](https://github.com/vmware/govmomi/blob/master/govc/USAGE.md#datastoreupload)
51-
- Once the image is uploaded to ESXi host, run `vmkfstools -i newRHEL.vmdk outputRHEL.vmdk -d thin`to ensure that, the `vmdk` image is ESXi compatible.
52-
- Create a new instance using that image. During the machine creation process, at the `Customize Hardware` step, press on ADD NEW DEVICE and select Existing Hard Disk.
53-
- In the Existing Hard Disk wizard select the rhel image file and then create the instance.
54-
- Use the instance name to clone rhel machine by updating the `MachineDeployment` field `.spec.template.spec.providerSpec.value.cloudProviderSpec.templateVMName`.
45+
46+
Find [here](./vsphere.md#RHEL) how to deploy a tempate VM in vSphere.

docs/vsphere.md

Lines changed: 255 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,267 @@
11
# VMware vSphere
22

3+
## Supported versions
4+
5+
* 6.5
6+
* 6.7
7+
8+
## Template VMs preparation
9+
310
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`.
518

6-
Ubuntu & CoreOS:
19+
### Create template VM from OVA
720

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
1227
3. Click through the dialog until "Select storage"
1328
4. Select the same storage you want to use for your machines
1429
5. Select the same network you want to use for your machines
1530
6. Leave everyhting in the "Customize Template" and "Ready to complete" dialog as it is
1631
7. Wait until the VM got fully imported and the "Snapshots" => "Create Snapshot" button is not grayed out anymore
1732

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.
19262

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

Comments
 (0)