Using rolling deployment with an Azure Load Balancer

joseph.dillon's Avatar

joseph.dillon

28 Jul, 2017 04:18 PM

Hi,
I'm trying to figure out a way to use the Rolling Deployment feature to deploy a web site to two Azure Virtual Machines (Web1 and Web2) behind an Azure Load Balancer. I have created a Rolling Deployment step with a Window Size of 1. I want to have zero downtime of the web site.

At the moment, the best way I can think of is to have a Manual Intervention step:
- for first iteration in the Rolling Deploy, the operator would remove Web1 from Load Balancer & Octopus would deploy to Web1.
- the second iteration in Rolling Deploy, operator would put Web1 back online, remove Web2 and deploy to Web2
Last step is to bring Web2 back online.

Would you say this is best practice, or would it be better to have steps in the Deployment (eg Powershell) to remove/add VMs from Load Balancer? If so can you point me to resource with example?

Cheers
Joe

  1. Support Staff 1 Posted by Daniel Fischer on 31 Jul, 2017 01:36 AM

    Daniel Fischer's Avatar

    Hi Joe,

    Thanks for getting in touch! It looks like you have the right idea here. While the Manual Intervention step will work, the best automated method for doing this is to create script steps to manage removing from the load balancer and then placing it back at the end. The following documentation page on our rolling deployments has a little bit more information on this.
    https://octopus.com/docs/patterns/rolling-deployments

    However, the idea is pretty much as you pointed out. Have a script step with PowerShell that manages the load balancing, which will remove the need for a manual intervention and manual management of the load balancer.

    Let me know if you have any further questions here or are hitting any road blocks. :)

    Best regards,
    Daniel

  2. 2 Posted by joseph.dillon on 03 Aug, 2017 02:35 PM

    joseph.dillon's Avatar

    Hi Daniel,

    I configured my deployment process with two Azure Powershell steps – one to take the current target out of the load balancer, then one to add the target back in to the load balancer.

    This is the script I’m using to take the current target out of the load balancer:

    $octoMachine = $OctopusParameters['Octopus.Machine.Name']

    $rgName = 'SandboxTest'
    $nicName = 'nic1'

    If ( $octoMachine -eq "Sandbox1" ) {
        Write-Output "About to take Sandbox1 out of Load balancer back end pool"
        $nicName = 'nic1'
    }
    If ( $octoMachine -eq "Sandbox2" ){
        Write-Output "About to take Sandbox2 out of Load balancer back end pool"
        $nicName = 'nic2'
    }
    $nic = Get-AzureRmNetworkInterface -ResourceGroupName $rgName -Name $nicName
    $nic.IpConfigurations[0].LoadBalancerBackendAddressPools = $null
    Set-AzureRmNetworkInterface -NetworkInterface $nic
    Write-Output "Done - removed from backend pool"

    This is working fine but feels a bit “hacky” with that IF statement and the hardcoded target names.

    Is there a better way to do this?

    Cheers
    Joe

  3. Support Staff 3 Posted by Daniel Fischer on 09 Aug, 2017 12:32 AM

    Daniel Fischer's Avatar

    Hi Joe,

    Thanks for getting back. Sorry for the delay in responding to you. We didn't really see a better way to do this than your solution. Not while the nickname is different to the Octopus machine name.
    One possible idea could be to append the nickname to the machine name. E.g: Sandbox1_nic1, then split by _.

    Let me know if you have any questions here?

    Best regards,
    Daniel

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • loadbalancer.png 40.5 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac