Does anyone have any example in Powershell, where you drain haproxy or nginx loadbalancers?
I can’t really find any good examples. Cause what I’m after is an rolling deployment.
Where I contact haproxy/nginx and drains server 1 , deploy , add server 1 and so on. Any direction on how to do it with Powershell scripts?
Thanks for getting in touch!
At this point, I’m not aware of any PowerShell examples that will do what you are looking. One of the main issues is Nginx and HAProxy load balancers both (usually) run on Linux and are therefore heavily config file based, and require modifications to these files to change configuration. As far as I’m aware, there’s no API you can call to drain servers etc.
However, with the release of PowerShell for Linux today (https://azure.microsoft.com/en-us/blog/powershell-is-open-sourced-and-is-available-on-linux/) you could potentially use an SSH target to connect to the Nginx server that runs a small bash script to execute PowerShell that modifies the configuration files to drain / remove / add as appropriate. (This could be done in pure bash script as well.)
Another potential option you could look at is Consul (https://consul.io). This does a whole lot more around service discovery and configuration, but you could use it in conjunction with Consul-Template (https://github.com/hashicorp/consul-template) to rewrite the appropriate configuration file in a fairly elegant fashion.
Hope that helps!
I solved it with writing an small node api.
using this lib: https://github.com/observing/haproxy
Thanks for some suggestions