Reads UPS details from a NUT server and automatically taint Kubernetes nodes with battery state to gracefully shed pods during a power outage. Intended to only augment and does not replace standard scripts to power down machines.
- Taints nodes as
ups.spikedhand.com/status=on-battery:NoSchedulewhile running on battery power. - Taints nodes as
ups.spikedhand.com/status=low-battery:NoExecuteif the UPS reports low battery. - Taints nodes as
ups.spikedhand.com/status=below-threshold:NoExecuteif the UPS is below 50% battery. - Removes the taint once the UPS is online again regardless of the charge level.
- My homelab has a small UPS.
- I want prioritize services that keep the network running well as long as possible because I work from home.
- Nova Scotia winter causes frequent short outages.
- Completely shutting down or draining a node for a usually short outage is overkill.
- Many home server applications are stateful and not designed for clusters. I'd prefer them to have shutdown well before a low battery requires them to be.
- Ensure your NUT server is configured to be network accessible to the cluster.
- Label all nodes with the appropriate UPS name configured in NUT. IE:
kubectl label node ${NODES} ups.spikedhand.com/name=${UPS_NAME} kubectl create ns ups-taintkubectl -n ups-taint create -f manifest/role.ymlkubectl -n ups-taint create -f manifest/deployment.yml- Create a secret named
nut-serverin theups-taintnamespace with username, password, and address. Alternatively update the deployment to provide the needed environment variables in another way.