[SOLVED] apcupsd (or NUT) Proxmox Cluster Shutdown

bnhf

New Member
Mar 20, 2023
6
4
3
Hoping to get a little input here from anybody using apcupsd (or NUT) to shutdown a Proxmox cluster.

I've been working on a suite of applications that containerize apcupsd, apcupsd-cgi, a TIG stack (Telegraf, InfluxDB2, Grafana for dashboard-style monitoring), and a Wake-on-LAN container for bringing systems back online after power is restored. It's all working well for traditional Linux (with Docker) and Windows environments. Next I'd like to get this suite of applications rocking-and-rolling with Proxmox.

Additional info on this project if you're interested:

https://www.reddit.com/r/homelab/comments/1359851/managing_multiple_apc_ups_units_including/
https://technologydragonslayer.com/...onitoring-with-apcupsd-admin-plus-and-docker/

235323855-837810a1-b6f2-40c2-a39a-eae360902178.png

I've been busy virtualizing "everything" on my network, and have seen first-hand the challenges with shutting Proxmox clusters without running into issues with quorum. My first thought in terms of an orderly shutdown (in the event of a power failure), is to install apcupsd (as a slave) in each container and virtual machine running in the Proxmox cluster. Based on the Googling I've done, this appears to be an important first step in shutting down a cluster. This should work, though obviously not everybody installs Docker in every CT or VM. apcupsd can, of course, be installed without being containerized -- which works well, but can get to be a bit of a juggling act when running on dozens of "slaves'.

I've been experimenting with the Proxmox API for shutdowns, and that works quite well for a single instance of Proxmox. What I'm wondering, particularly from those of you who've been in the trenches with this issue -- is there a way to scale an API shutdown to a cluster? For example, does the API support first shutting down all CTs/VMs and then shutting down the cluster? And if so, what's the syntax for that API call using curl?
 
AFAIK you would need to shutdown all VMs/CTs first in multiple API calls and then do a cluster shutdown by shutting down the nodes (via poweroff on the shell).
Since installing apcupsd is easy enough, either using my containerized version or directly in the CT or VM, I decided to go that route. Keeps things synergistic with the overall approach.

Once all the CTs/VMs have automatically shut themselves down (in the event of a power outage, and subsequent message from a UPS-connected host), then the Proxmox host(s) will be shutdown using an API call per host just before that last SBC shuts itself and the UPS down. All tested and looking good!

Once power is restored, only one SBC needs to power-up and it'll wake-up anything else required using the companion Wake-on-LAN container. There's a variable delay on those wake-up calls too -- for better certainty that the power has been on for a few minutes and is likely stable.

GitHub project pages here for anyone interested:

https://github.com/bnhf/apcupsd-master-slave
https://github.com/bnhf/apcupsd-admin-plus
https://github.com/bnhf/wolweb

or pull the containers off Docker Hub, using the README there for Portainer-ready Docker-compose examples:

https://hub.docker.com/repository/docker/bnhf/apcupsd
https://hub.docker.com/repository/docker/bnhf/apcupsd-cgi
https://hub.docker.com/repository/docker/bnhf/wolweb
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!