Arc resource bridge via powershell
… 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 -SkipPublisherCheck
Install-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
$clusterRoleName1 = $clusterRoleName
$csv_path1 = $csv_path
$cloudServiceIP1 = $cloudServiceIP
Set-MocConfig `
-clusterRoleName $clusterRoleName1 `
-workingDir "$csv_path1\ResourceBridge" `
-imageDir "$csv_path1\imageStore" `
-skipHostLimitChecks `
-cloudConfigLocation "$csv_path1\cloudStore" `
-catalog aks-hci-stable-catalogs-ext `
-ring stable `
-CloudServiceIP $cloudServiceIP1 `
-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