Quick tip – Arc resource bridge via powershell – working for AS HCI 22H2
Setup your powershell environment
Install-PackageProvider -Name NuGet -Force
Install-Module -Name PowershellGet -Force -Confirm:$false -SkipPublisherCheckInstall-Module -Name Moc -Repository PSGallery -AcceptLicense -Force
Initialize-MocNode
Install-Module -Name ArcHci -Force -Confirm:$false -SkipPublisherCheck -AcceptLicense
Define variables for the MOC:
$vswitchName=”ConvergedSwitch(compute)”
$controlPlaneIP=”10.10.0.37″
$csv_path=”C:\ClusterStorage\Volume01\Arc”
$vlanID=”57″ #(Optional)
$VMIP_1=”10.10.0.38″ #(required only for static IP configurations)
$VMIP_2=”10.10.0.39″ #(required only for static IP configurations)
$DNSServers=@(“10.10.0.30″,”10.10.0.31″) #(required only for static IP configurations)
$IPAddressPrefix=”10.10.0.0/24″ #(required only for static IP configurations)
$Gateway=”10.10.0.1″ #(required only for static IP configurations)
$cloudServiceIP=”10.10.0.40” #(required only for static IP configurations)
$clusterRoleName = “arc-hci01-mocagent”
Install the MOC
Set-MocConfig -clusterRoleName $clusterRoleName -workingDir $csv_path\ResourceBridge -imageDir $csv_path\imageStore -skipHostLimitChecks -cloudConfigLocation $csv_path\cloudStore -catalog aks-hci-stable-catalogs-ext -ring stable -CloudServiceIP $cloudServiceIP -createAutoConfigContainers $false
Install-Moc
Define the variables for the Azure resources:
$resource_group=”rg-azurestackhci”
$subscription=”1234-1234567890-1234″
$location=”australiaeast”
$customloc_name=”cl-hci01-hci”
Login to Azure and register the resource providers
#az login –use-device-code
az account set –subscription $subscription
az provider register –namespace Microsoft.Kubernetes –wait
az provider register –namespace Microsoft.KubernetesConfiguration –wait
az provider register –namespace Microsoft.ExtendedLocation –wait
az provider register –namespace Microsoft.ResourceConnector –wait
az provider register –namespace Microsoft.AzureStackHCI –wait
az provider register –namespace Microsoft.HybridConnectivity –wait
Deploy the Arc appliance. Each step takes a bit so do 1 at a time:
$resource_name= ((Get-AzureStackHci).AzureResourceName) + “-arcbridge”
mkdir $csv_path\ResourceBridge
New-ArcHciConfigFiles -subscriptionID $subscription -location $location -resourceGroup $resource_group -resourceName $resource_name -workDirectory $csv_path\ResourceBridge -controlPlaneIP $controlPlaneIP -vipPoolStart $controlPlaneIP -vipPoolEnd $controlPlaneIP -k8snodeippoolstart $VMIP_1 -k8snodeippoolend $VMIP_2 -gateway $Gateway -dnsservers $DNSServers -ipaddressprefix $IPAddressPrefix -vswitchName $vswitchName -vLanID $vlanID
az arcappliance validate hci –config-file $csv_path\ResourceBridge\hci-appliance.yaml
az arcappliance prepare hci –config-file $csv_path\ResourceBridge\hci-appliance.yaml
az arcappliance deploy hci –config-file $csv_path\ResourceBridge\hci-appliance.yaml –outfile $env:USERPROFILE\.kube\config
az arcappliance create hci –config-file $csv_path\ResourceBridge\hci-appliance.yaml –kubeconfig $env:USERPROFILE\.kube\config
az arcappliance show –resource-group $resource_group –name $resource_name
Once the Arc appliance is deployed, register it to Azure.
$hciClusterId= (Get-AzureStackHci).AzureResourceUri
az k8s-extension create –cluster-type appliances –cluster-name $resource_name –resource-group $resource_group –name hci-vmoperator –extension-type Microsoft.AZStackHCI.Operator –scope cluster –release-namespace helm-operator2 –configuration-settings Microsoft.CustomLocation.ServiceAccount=hci-vmoperator –configuration-protected-settings-file $csv_path\ResourceBridge\hci-config.json –configuration-settings HCIClusterID=$hciClusterId –auto-upgrade true
az k8s-extension show –cluster-type appliances –cluster-name $resource_name –resource-group $resource_group –name hci-vmoperator –out table –query ‘[provisioningState]’
az customlocation create –resource-group $resource_group –name $customloc_name –cluster-extension-ids “/subscriptions/$subscription/resourceGroups/$resource_group/providers/Microsoft.ResourceConnector/appliances/$resource_name/providers/Microsoft.KubernetesConfiguration/extensions/hci-vmoperator” –namespace hci-vmoperator –host-resource-id “/subscriptions/$subscription/resourceGroups/$resource_group/providers/Microsoft.ResourceConnector/appliances/$resource_name” –location $location
If you got this far without error, then you have a connected Arc resource bridge.
To clean up and start again
## UNINSTALL
az azurestackhci virtualnetwork delete –subscription $subscription –resource-group $resource_group –name $vnetName –yes
az azurestackhci galleryimage delete –subscription $subscription –resource-group $resource_group –name $galleryImageName
az customlocation delete –resource-group $resource_group –name $customloc_name –yes
az k8s-extension delete –cluster-type appliances –cluster-name $resource_name –resource-group $resource_group –name hci-vmoperator –yes
az arcappliance delete hci –config-file $csv_path\ResourceBridge\hci-appliance.yaml –yes
Remove-ArcHciConfigFiles
Uninstall-Moc
Cheers