- Configure the Network Protocol Profile on the vCenter according to: https://www.virtualthoughts.co.uk/2020/03/29/rancher-vsphere-network-protocol-profiles-and-static-ip-addresses-for-k8s-nodes/
- Ensure to create a service user with the regarding global and folder specific permissions: https://rancher.com/docs/rancher/v2.x/en/cluster-provisioning/rke-clusters/node-pools/vsphere/provisioning-vsphere-clusters/creating-credentials/
- Beside the vCenter role permissions from the official Rancher documentation, the following ones need to be provided in order to configure the Nodes via vApp options:
- Content Library: Read storage
- Extension: Register extension
- vSphere Tagging: Assign or Unassign vSphere Tag on Object
- Profile-driven storage: Profile-driven storage view
- vApp: Add virtual machine, Assign resource pool, Import, View OVF environment, vApp application configuration, vApp instance configuration
- Beside the vCenter role permissions from the official Rancher documentation, the following ones need to be provided in order to configure the Nodes via vApp options:
Configure stuff like networking, folder, CPU, memory, etc.
Add the following cloud-init config YAML:
#cloud-config
users:
- name: master
shell: /bin/bash
groups: wheel
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh-authorized-keys:
- ssh-rsa AAAABaEQ...PbQ== My Awesome Key
packages:
- open-vm-tools
write_files:
- path: /root/configure-netplan.sh
content: |
#!/bin/bash
vmtoolsd --cmd 'info-get guestinfo.ovfEnv' > /tmp/ovfenv
IPAddress=$(sed -n 's/.*Property oe:key="guestinfo.interface.0.ip.0.address" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv)
SubnetMask=$(sed -n 's/.*Property oe:key="guestinfo.interface.0.ip.0.netmask" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv)
Gateway=$(sed -n 's/.*Property oe:key="guestinfo.interface.0.route.0.gateway" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv)
DNS=$(sed -n 's/.*Property oe:key="guestinfo.dns.servers" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv)
cat > /etc/netplan/01-netcfg.yaml <<EOF
network:
version: 2
renderer: networkd
ethernets:
ens192:
addresses:
- $IPAddress/27
gateway4: $Gateway
dhcp6: no
accept-ra: no
nameservers:
addresses : [$DNS]
EOF
sudo netplan apply
sleep 30
sudo systemctl start open-vm-tools
runcmd:
- bash /root/configure-netplan.sh
bootcmd:
- [ cloud-init-per, once, rmdefaultnetconf, rm, -f, /etc/netplan/50-cloud-init.yaml ]
- [ cloud-init-per, once, tempstopvmtools, sudo, systemctl, stop, open-vm-tools ]
Please note: The "hack" with the open-vm-tools
service is required since otherwise Rancher will try to connect to the nodes using the temporarily link-local IPv6 or temporarily DHCP IPv4 address. This would prevent Rancher from being able to access the notes in order to install Docker etc..
Check Provide a custom vApp config
and set the following values (replace vlan-123
with the actual port group name!):
com.vmware.guestInfo
IPv4
fixedAllocated
guestinfo.interface.0.ip.0.address
ip:vlan-123
guestinfo.interface.0.ip.0.netmask
${netmask:vlan-123}
guestinfo.interface.0.route.0.gateway
${gateway:vlan-123}
guestinfo.dns.servers
${dns:vlan-123}
- Fisit https://rancher.example.com/g/clusters/add/select and select
vSphere
- Fill out the regarding options:
Cluster Name
:test
- Create two type of node groups:
- Master nodes:
Name Prefix
:test-master-
Count
:3
Template
:Ubuntu Bionic Master Test
Auto Replace
:0 minutes
(default value)etcd
: checkedControl Plane
: checkedWorker
: uncheckedTaints
: none (default value)
- Worker nodes:
Name Prefix
:test-worker-
Count
:3
Template
:Ubuntu Bionic Worker Test
Auto Replace
:0 minutes
(default value)etcd
: uncheckedControl Plane
: uncheckedWorker
: checkedTaints
: none (default value)
- Master nodes:
Member Roles
: Addadmins
asOwner
- For the
Kubernetes Options
section, just click onEdit as YAML
and replace the whole shown YAML with the one from1-cluster-template.yaml.tmpl
(or at least add thecloud_provider
section). - Click
Create
.
Apply 2-vsphere-thin-standard.yaml
(replace MY-VMWARE-DATA-STORE
with your actual datastore name from the vSphere cluster): kubectl apply -f 2-vsphere-thin-standard.yaml
Thanks for sharing this publicly.
I'm having trouble replicating -- what version of ESXi are you running? Could you also provide details about how you created the VM template?
Thank you!!