UPI on VMware - Windows DNS

Latest response

Guys, struggling with UPI on vmware with windows DNS infrastructure. Trying to created an automated deployment pipeline but windows DNS only really supports automation with powershell on windows (core does not have the modules). Anyone successfully been deploying on vmware with widows DNS? Any advice?

Responses

I reserve my IP's by mac address in advance. I use a powershell script on linux to clone the 4.2 ova in vsphere to the desired number of vm's, changing the mac address to the one I reserved. The vm's start with a reserved mac, get assigned their IP and hostname. Is that what you are looking for?

Thanks Paul. yes, I was considering that bu I have large VMWare estate. How are you ensuring now MAC overlaps/conflicts? I'm not sure you can assign a MAC scheme to a cluster? seem sit has ot be done at the vCentre level. as this https://docs.vmware.com/en/VMware-vSphere/6.5/com.vmware.vsphere.networking.doc/GUID-290AE852-1894-4FB4-A8CA-35E3F7D2ECDF.html

Our VMWare Engineers created a vcenter and a service account just for the Openshift environment. The service account's assigned roles and privileges can only affect the OpenShift environment. This limits my destructive power... From http://www.vmwarearena.com/how-vcenter-assigns-mac-addresses-to-vmware-virtual-machines/ this gives us 65000 mac addresses to play with. We hope to automate our current manual process of -deploy a vm -grab it's new vmware assigned mac address -dhcp reserve an ip based on that mac address and assign a host name to it Once the mac is reserved I can delete/recreate the cluster vm's with a powershell script running on my linux deployment server. I can't find anthing documenting the vsphere mac address recycle time/method but I've not experienced any issues due to our reserved mac addresses in the last 300 redeploys. Our powershell guy wrote this: (deletes the old and deploys a new)

$ cat  > deploy-with-pwrshell-sandbox.ps1 <<EOF
function Invoke-NewVM {
  param([string]$vmName, [string]$vmMac, [string]$igPath)
  $IgData = Get-Content -Path $igPath
  $MYHOST = Get-Cluster | get-vmhost | where {$_.connectionstate -eq "Connected"} | Get-Random
  $MYDATASTORE = $MYHOST | Get-Datastore | where {$_.capacitygb -gt 100}  | Get-Random
  New-VM -Name $vmName -vm 'rhcos-4.2.0-x86_64-vmware'  -VMHost $MYHOST -Datastore $MYDATASTORE -DiskStorageFormat thin
  get-vm $vmName | Get-NetworkAdapter | Set-NetworkAdapter -MacAddress $vmMac -Confirm:$false
  $testagain = Get-VM -Name $vmName
  $spec = New-Object VMware.Vim.VirtualMachineConfigSpec
  $spec.vAppConfig = New-Object VMware.Vim.VmConfigSpec
  $spec.vAppConfig.property = New-Object VMware.Vim.VAppPropertySpec[] (2)
  $spec.VAppConfig.Property[0] = New-Object VMware.Vim.VAppPropertySpec
  $spec.vAppConfig.property[0].operation = "edit"
  $spec.vAppConfig.property[0].info = New-Object VMware.Vim.VAppPropertyInfo
  $spec.vAppConfig.property[0].info = $testagain.ExtensionData.Config.VAppConfig.Property | Where-Object {$_.Label -eq 'Ignition config data encoding'}
  $spec.vAppConfig.property[0].info.value = "base64"
  $spec.vAppConfig.property[0].info.defaultvalue = "base64"
  $spec.VAppConfig.Property[1] = New-Object VMware.Vim.VAppPropertySpec
  $spec.vAppConfig.property[1].operation = "edit"
  $spec.vAppConfig.property[1].info = New-Object VMware.Vim.VAppPropertyInfo
  $spec.vAppConfig.property[1].info = $testagain.ExtensionData.Config.VAppConfig.Property | Where-Object {$_.Label -eq 'Ignition config data'}
  $spec.vAppConfig.property[1].info.value = $IgData
  $spec.vAppConfig.property[1].info.defaultvalue = $IgData

  $testagain.ExtensionData.ReconfigVM_Task($spec)
  Get-vm $vmName    | Start-VM -Confirm:$false
}
Get-Module -ListAvailable PowerCLI* | Import-Module
$vcenters = "your.vcenter.server"
$vcenteruser="vmware_openshift_account"
$vcenterpass="password"
Connect-VIServer $vcenters  -User $vcenteruser -Password $vcenterpass

Get-vm bootstrap | Stop-VM -Confirm:$false
Get-vm master-01 | Stop-VM -Confirm:$false
Get-vm master-02 | Stop-VM -Confirm:$false
Get-vm master-03 | Stop-VM -Confirm:$false
Get-vm worker-01 | Stop-VM -Confirm:$false
Get-vm worker-02 | Stop-VM -Confirm:$false
Get-vm worker-03 | Stop-VM -Confirm:$false

Get-vm bootstrap | Remove-VM -Confirm:$false -DeletePermanently
Get-vm master-01 | Remove-VM -Confirm:$false -DeletePermanently
Get-vm master-02 | Remove-VM -Confirm:$false -DeletePermanently
Get-vm master-03 | Remove-VM -Confirm:$false -DeletePermanently
Get-vm worker-01 | Remove-VM -Confirm:$false -DeletePermanently
Get-vm worker-02 | Remove-VM -Confirm:$false -DeletePermanently
Get-vm worker-03 | Remove-VM -Confirm:$false -DeletePermanently

Invoke-NewVM -vmName "bootstrap" -vmMac "00:50:56:87:2d:c0" -igPath "/home/ansible/sandbox/append-bootstrap.ign.64"
Invoke-NewVM -vmName "master-01" -vmMac "00:50:56:87:c0:2a" -igPath "/home/ansible/sandbox/master.ign.64"
Invoke-NewVM -vmName "master-02" -vmMac "00:50:56:87:ad:97" -igPath "/home/ansible/sandbox/master.ign.64"
Invoke-NewVM -vmName "master-03" -vmMac "00:50:56:87:16:05" -igPath "/home/ansible/sandbox/master.ign.64"
Invoke-NewVM -vmName "worker-01" -vmMac "00:50:56:87:c4:9d" -igPath "/home/ansible/sandbox/worker.ign.64"
Invoke-NewVM -vmName "worker-02" -vmMac "00:50:56:87:93:ae" -igPath "/home/ansible/sandbox/worker.ign.64"
Invoke-NewVM -vmName "worker-03" -vmMac "00:50:56:87:db:9d" -igPath "/home/ansible/sandbox/worker.ign.64"

Start-VM -Confirm:$false -VM "bootstrap"
Start-VM -Confirm:$false -VM "master-01"
Start-VM -Confirm:$false -VM "master-02"
Start-VM -Confirm:$false -VM "master-03"
Start-VM -Confirm:$false -VM "worker-01"
Start-VM -Confirm:$false -VM "worker-02"
Start-VM -Confirm:$false -VM "worker-03"
Disconnect-ViServer -Force -Confirm:$false
EOF

That's a clever way of getting a unique set of Mac addresses to use! We are using Terraform so might be a little tricky do do something similar but I'm going to check it out. Windows DNS is a nightmare though as the powershell modules requires the .DLL file from the DNS.MSC which is only available on Windows. I have not seen that module ported to powershell core yet :(