DIY UPS for RPi Cluster - Work In Progress

LiPo-based DIY UPS with Arduino controller to protect the cluster from power outages

Problem to Solve

A Kubernetes cluster does not shut down gracefully on power loss. Without a proper shutdown, Longhorn can end up in an inconsistent state with corrupted PVCs. Commercial UPS units are expensive and oversized for this use case.

Solution

A DIY UPS built from:

  • 2 × LiPo 18650 cells in parallel (~10 Ah)
  • TP4056 charge controller with built-in protection
  • DC-DC boost module 5V/3A to power the Pis
  • Arduino Nano for supervision

Control Logic

The Arduino reads the battery voltage every 10 seconds through a resistive divider + ADC. When voltage drops below 3.6V/cell (mains off and battery draining), it sends a GPIO signal to the designated “master shutdown” Pi.

That Pi runs a Bash script that:

  1. Gracefully pauses all pods (except k3s and longhorn)
  2. Triggers sequential shutdown of worker nodes
  3. Shuts itself down last

Result

The cluster would survive micro-outages with zero data corruption. Total cost: ~€50.