I’m working on doing blue/green deployments where blue is on a different set of servers than green. I would like to have a script (powershell) run on blue when deploying to green and run on green when deploying to blue. I need to delete/create files on the different environment servers that the load balancer uses to determine where to send the requests. The closest thing I have found is to run the script on the octopus server and use the domain account that the server runs under to talk to a file share. However, we’re about to setup a new set that will not be on the same domain, nor have access to file shares on the target server so this option isn’t going to work very well. Is there any way to do this?
Hi there
Thanks for reaching out!
There are a few ways to do what you are trying to achieve. You could ave a tentacle shared between each environment that answers the load balancer pings (whether thats a separate machine or an application machine, it wouldnt matter).
You could have an orchestration project that triggers the deployment to the appropriate environment, then updates the other environment to “disable” it.
Depending on your load balancer, you should be able to use the load balancers API directly to modify which servers are live.
Hope that helps!
Regards,
Matt
Hi there
We just had an internal discussion about this, and another suggestion came up:
You can actually register the same machine twice with different roles. (It just needs a different name, and you would want roles different but all other details are the same.)
So, you could have :
-
WebBlue01
inProduction - Blue
with a roleweb-server
-
WebBlue01
inProduction - Green
with a rolenon-active-web-server
-
WebGreen01
inProduction - Blue
with a rolenon-active-web-server
-
WebGreen01
inProduction - Green
with a roleweb-server
You could then have a step targeted at non-active-web-server
which deletes those files.
Hope that helps!
Regards,
Matt
That might be a whole lot easier. I started going down the path of an orchestration environment and it is a whole lot of scripting which feels kind of hacky… I’ll give this a try.
So, looking at the UI I can’t find a way of adding a role to a specific environment…I can add it to multiple environments and multiple roles, but not roles for a specific environment. Am I missing it somewhere? I could probably add 4 roles (production-blue, stage-blue, production-green, stage-green) but that starts to get a little large when we add a 3rd environment (stage->internal->production).
Hi there
You will need to add a new deployment target for the machine with the same thumbprint, hostname and port, but with a different role.
Hope that helps!
Regards,
Matt
Thanks, I’ll give it a try.
It’s taken a while to get the deployment process nailed down for this project. But adding the tentacle in twice as you suggested worked great.
There was a few gotcha’s that we had to work around though.
- Tentacle names have to be unique (makes sense). We were using FQDN names, but with the additional data in the name to make it unique it was wrapping around so we needed to come up with a shorter naming scheme. We just chose (b|g).
- C# scripting documentation is lacking. I was able to figure out what I needed except for setting exit codes to get a script to block the deployment. I ended up just throwing an exception which worked.
- Lifecycles/Environments/Roles takes some time to really understand them
- The new certificate management feature is great! <- not much of a gotcha… it ended up saving me a bunch of time
- There are a decent number of bugs in the community step templates that I was trying to use
- Creating a scheduled task requires a password - it’s missing an if statement
- Setting log folder location for IIS doesn’t use formatting correctly when putting variables into the string. - xpath selector strings were being built incorrectly
- Ensuring windows features are installed wasn’t working at all - don’t remember the exact problem, just rolled my own
All in all though, I’ve found that the deployment process is now relatively straight forward and easy to maintain for this project. We ended up with about 50 steps.
Thanks for your help!
-Ed-
Hi Ed
Glad to hear you’ve got it resolved.
Can you give me a bit more detail about what you’d expect to find in the docs regarding the c# scripts? Always good if we can get real world experience to drive the content people want to see
Regarding the community templates, are you able to submit a PR with the fixes? That way the community can avoid the pain you’ve gone through.
Thanks in advance!
Regards,
Matt
I can do some pull requests sure. I’ll try and get them done within the next few days.
I would have expected to find some information as to how to stop a deployment through the script by setting an exit code. Also more information on the Octopus class that is used to gain access to variables and some other information about the deployment. I ended up writing a script that used reflection to dump out methods/properties/variables available. It wasn’t until the very end of the process that I found out about the 2 variables you can set to get the available variables and their values. I still have yet to find out how to set a variable in the C# script that will then be passed to other steps. I think I saw how to do it in powershell buried in the docs somewhere when I first started going down the route of the orchestration project.
Hi Ed
Many thanks for your PRs - appreciate it.
Also thanks for your comments on the docs - I’ve added a task to the backlog to improve the docs in this area. Hopefully we can make it easier for others in the future.
Happy deployments!
Regards,
Matt