Automatic deployment to a load balanced environment

cam's Avatar

cam

13 Mar, 2017 06:15 PM

Hi all,

I've got to configure an automatic deployment process for a load balanced web application and I'd like to validate my solution before actually implementing it. I have 3 servers and this is what I have to do for each one:

* Disconnect the server from the load balancer (before-deploy script)
* Make the deployment
* Check the deployment with a Selenium test (after-deploy script)
* Connect the server to the load balancer again
* Trigger a deployment to the next server

My questions with this workflow are:

* How can I make a decision based on the results of a Selenium test?
* How can I trigger the next deployment if everything was ok? I was thinking about using AppVeyor's API.
* How can I make a rollback if any of the deployments fail?

Cheers!

  1. 1 Posted by Ilya Finkelshte... on 14 Mar, 2017 03:33 AM

    Ilya Finkelshteyn's Avatar

    Hello,

    • I believe that if Selenium tests command failed, exit code will be other than 0. So you can check if last command failed according to this doc.
    • You can trigger deployment with API, here is an example. Note that you will be needed to store API token as a secure variable and pass it to Environment deployment.
    • We have not rollback functionality, but you can just redeploy last successful build.

    However I think that scenario with Selenium tests on every server is a little fragile. Maybe better do Selenium test only on AppVeyor VM, after the build. Here is some notes. And as part of deployment script do only lightweight testing with invoke-webrequest command.

    Thanks!
    Ilya.

  2. 2 Posted by cam on 14 Mar, 2017 12:06 PM

    cam's Avatar

    Hi Ilya,

    Thank you for your response, I'll have everything clearer now.

    Cheers.

  3. 3 Posted by Ilya Finkelshte... on 14 Mar, 2017 05:51 PM

    Ilya Finkelshteyn's Avatar

    Sure, please feel free to ping with any questions when implementing it.

  4. 4 Posted by andrew on 16 Mar, 2017 12:18 PM

    andrew's Avatar

    Hi,

    We have been doing very similar with AppVeyor for a number of months. I am having an issue whereby machines that go through the deployment process command though are being re-deployed, so for example:

    - Machine 1 starts up, initialises and runs the deployment script which sends the deployment message to AppVeyor, the machine gets deployed.
    2. Second machine comes up, runs through the same process and runs the deployment. As machine 1 is in the same group, it deploys to both machines.

    Is there a way to deploy to just the one machine?

    Andrew.

  5. 5 Posted by Ilya Finkelshte... on 16 Mar, 2017 11:53 PM

    Ilya Finkelshteyn's Avatar

    @Andrew could you please provide more details about your environment? Are all servers use the same Environment access key? Is your application have multiple tiers (main reason to have a groups)? Also please check this post if you did not do it already, to get good example of groups usage.

    Thanks!
    Ilya.

  6. 6 Posted by andrew on 17 Mar, 2017 09:05 AM

    andrew's Avatar

    Hi,

    We have a single environment called production and in that environment I have several servers in different groups. There are multiple servers per groups (i.e, multiple front-end machines, multiple back-end machines etc. From the URL you posted, I don't think there is any way to target a specific server for deployment, and I would say this would be a really good feature to have for auto-scaling environments, as with the current solution if a tier autoscales, it causes a re-deployment to all servers in that environment.

    Thanks.
    Andrew.

  7. 7 Posted by cam on 17 Mar, 2017 01:42 PM

    cam's Avatar

    Hi All,

    I've been able to configure my deployment flow.
    I'm using web deploy so I created 3 different environments in AppVeyor, one for each server, let's call them E1, E2 and E3. This is how the deploy works:

    * I push to a git branch that triggers a deployment to E1
    * E1 disconnects itself from the load balancer through a before deployment command.
    * E1 gets deployed
    * E1 connects itself to the load balancer again and trigger the deployment to E2 through an after deployment command.
    * E2 disconnects itself from the load balancer through a before deployment command.
    * E2 gets deployed
    * E2 connects itself to the load balancer again and trigger the deployment to E3 through an after deployment command.
    * E3 gets deployed

    So far so good, this flow works perfectly.
    The missing part is the selenium test which I don't know how to configure.

    I already have the test but I don't know how to make it work in AppVeyor, these are my questions:

    * Which URL should I use for the test?
    * in which step of the pipeline does it get executed?

    I'd like to execute it after E1 gets deployed and before it connects itself to the load balancer.

    Cheers,
    Cristhian.

  8. 8 Posted by Ilya Finkelshte... on 17 Mar, 2017 04:47 PM

    Ilya Finkelshteyn's Avatar

    @cam

    Please see my answers below:

    • Which URL should I use for the test?

      • You can use http://localhost, if your website does not user host headers. If it does, you can create record like 127.0.0.1 www.yoursite.com in hosts file. Samples are here. It is good idea to restore hosts file after your test finished.
    • in which step of the pipeline does it get executed?

      • in after-deploy script, before server connects itself to load balancer back.
  9. 9 Posted by Ilya Finkelshte... on 17 Mar, 2017 04:53 PM

    Ilya Finkelshteyn's Avatar

    @Andrew I agree, we plan major improvements for deployment this year, will take this into account. For now I believe to avoid deployment duplication, you have to create separate environment for each server as @cam did.

  10. 10 Posted by Ilya Finkelshte... on 17 Mar, 2017 06:11 PM

    Ilya Finkelshteyn's Avatar
  11. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:15 AM.

Comments are currently closed for this discussion. You can start a new one.

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