How do you change Rolling Deployment window size for Dev/Test, Production and for Scaling events?

Hi,

I have some requirements that I need help with using Rolling Deployments.

We are deploying a large corporate .NET CMS.

In Dev/Test, we have 2 Virtual Machines we use, and in Production, we use 6. For Dev and Test, I’d like to set the deployment window size to 100% and Production to 50%.

One further thing to consider is that we often bring on new Virtual Machines to deal with the website load, and we go from 6 to 12 deployment targets. When this happens, we want to deploy to all 6 virtual machines that we have just created but not to the original 6 Virtual Machines. How do I go about doing that?

Hi,

Thanks for getting in touch.

This is achievable. I’ll start with how to use Rolling Deployments.

As you have mentioned your deployments in %, we have a community step template called Determine Rolling Deploy Windows size that I would use.

I’ve set up the below deployment process, and I’ll take you through each step.

Deployment process

image

** Manual Intervention Step**

In this step, I use #{unless Octopus.Deployment.Trigger.Name}True#{/unless} and set it to only run on Production for my Run condition.

This means that the manual intervention step will only run in Production and when the deployment is kicked off manually from inside of Octopus.

Determining the Rolling Deploy Window Size as a %

I used the community step template and an Octopus variable to set the %.

Variables

I created a variable called Project.Parallel.Deployments and created one for Dev/Test and input the value of 100. This will allow for all deployment targets to be deployed to in Development and Test.

For Production, I input #{if Octopus.Deployment.Trigger.Name == “Test”}100#{else}50#{/if}. What this will do, is have a window of 50% of deployments that are kicked off manually.

This variable will also set the deployment window size for the Rolling Deployment to 100% if it’s kicked off by a Deployment target trigger called Test. I’ll come back to this later.

Rest of the Deployment process

The rest of the deployment process is like any other Rolling Deployments, and for the most part, I’ll only cover this high-level. They are demo Powershell scripts and mostly can be ignored as your step will likely be more real world.

Parent Step

Demo Script 1

Demo Script 2

Demo Script 3

Creating the Trigger

As you’ve mentioned that you scale, you will want to use a Deployment target trigger.

To do this, you can browse to Deployments -> Triggers -> Add a Deployment target trigger.

I set it up as below, but you may want to change the event type based on your scenario.

I named this Trigger Test. This part is important. You’ll see in the previous section I created the variable #{if Octopus.Deployment.Trigger.Name == “Test”}100#{else}50#{/if}. What does this mean?

Here, I specified that the Trigger must be called Test, and I specified that it would be 100 if the deployment trigger creates the deployment, or if it’s manually deployed, it will do 50%.

If you had a trigger called Autoscale and wanted to do 25% manually and 50% if it’s automatically deployed, then the variable would be #{if Octopus.Deployment.Trigger.Name == “Autoscale”}50#{else}25#{/if}

** Dev Deployment**

I created a release and deployed this to development and confirmed that all targets were deployed to at the same time.

Test Deployment

This happened exactly like Dev.

Production Deployment

In Production, it ran on 50% of the targets and then on the second set of targets.

.

At this point, everything is working as expected. But, what happens when I scale my Infrastructure?

In my example, I used Cloud Regions as my deployment target as they are a good example when doing Proof of Concepts.

In the production deployment, you notice that there are 6 deployment targets deployed to. This was because I had 6 enabled.

For Web7 through 12, I then enabled these deployment targets.

Production Deployment - Scaling event

As I was manually enabling these, I noticed it went ahead and deployed to 10 and 11, and this was because I enabled these first. It grabbed two and then the remaining four and deployed all within a few seconds of one another.

.

This should get you to where you want to be, but a tip I would provide is to find a way to enable your deployment targets all at the same time so you get all 6 deployments to your newly scaled machines.

Please let me know if you have any questions,

Derek