Skip to content

Instantly share code, notes, and snippets.

@skinny
Last active March 9, 2023 13:20
Show Gist options
  • Save skinny/caec07c75b16f7a90b7fffa4b577508c to your computer and use it in GitHub Desktop.
Save skinny/caec07c75b16f7a90b7fffa4b577508c to your computer and use it in GitHub Desktop.
lb change
  • Create a new temporary LB in the same RG as the AKS LB (templb)

  • Create an empty backendpool on this LB (temppool)

  • Run

RG=MC_rg-k8s-test_k8s-test_westeurope
az vmss update --resource-group $RG --name aks-agentpool-33436152-vmss \
--remove virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].loadBalancerBackendAddressPools 0

This will remove the vmss from the outbound pool on the AKS LB

  • Add the VMSS to this 'temppool'. This will be the 2th pool the VMSS is connected to (next to the remaining inbound AKS one)
  • Run again :
RG=MC_rg-k8s-test_k8s-test_westeurope
az vmss update --resource-group $RG --name aks-agentpool-33436152-vmss \
--remove virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].loadBalancerBackendAddressPools 0

To force remove the VMSS from the AKS LB (inboud) pool

  • Apply the update to the VMSS to allow for LB removal

az vmss update-instances --instance-ids "*" -n aks-agentpool-33436152-vmss -g $RG

  • Delete the 'kubernetes' LB via the Azure portal

  • Reconcile the AKS cluster az resource update --ids "/subscriptions/b5344c36-1e01-44b0-ad21-272b99cd6612/resourcegroups/rg-k8s-test/providers/Microsoft.ContainerService/managedClusters/k8s-test"

this will recreate the default 'kubernetes' LB, with two backendpools and add the VMSS to those pools

  • Remove the VMSS from the temppool
az vmss update --resource-group $RG --name aks-agentpool-33436152-vmss \
--remove virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].loadBalancerBackendAddressPools 0
  • Delete the temporary load balancer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment