Private cloud platform
Everything three products run on, from the servers to the firewall to the backups, defined in code.
Built at MDN Labs, 2026
What it is
- A private OpenStack cloud that runs three products: Odyssey in development, QA, demo and production, BABIS in development and production, and the inference gateway BABIS calls.
- I built it from scratch and own all of it: servers, networks, the edge proxy and firewall, the private network, monitoring, backups and release pipelines.
- Every machine, network and firewall rule is written in Ansible, so the whole platform lives in one repository.
The problem
The products ran on single virtual machines. I moved them onto a private cloud I set up.
Three products needed somewhere to run: production databases, background workers, an identity server, an AI service, and the tools to watch over all of it, each in several environments.
Because I built it from the ground up, I could set the rules: everything in code, internal tools kept off the public internet, alerts that cut through noise, and backups proven by actually restoring them.
How I built it
- Every VM, subnet and security group is declared in Ansible and provisioned on OpenStack. Debian 13 machines are split across five isolated subnets: one each for Odyssey and BABIS, plus public services, management and tools, and every VM also sits on the management network.
- PostgreSQL, Redis and RabbitMQ are reusable Ansible roles with typed argument specs, so a missing or mistyped input fails before the host is touched. Each image is pinned to a reviewed manifest digest, not a tag that can move.
- Secrets live in Ansible Vault. Every Compose file is rendered as a candidate, checked with docker compose config --quiet and only then swapped in atomically. The --quiet matters: without it, the check would print the resolved secrets into the log.
- Grafana Alloy on the app and proxy VMs ships logs to Loki, which keeps them for 180 days, and through an OTLP bridge to Graylog. Request and task IDs stay fields, never Loki labels, so one request never becomes its own stream.
- A Graylog pipeline I reconcile through its REST API normalises the OpenTelemetry attributes, so logs from every service look the same.
- Prometheus scrapes every VM, the bare-metal hypervisor and the inference gateway’s own metrics, with provisioned Grafana dashboards for the infrastructure and each product.
The interesting parts
Matching the container MTU to the overlay
OpenStack carries VM traffic inside VXLAN tunnels, so the VMs’ network interfaces have an MTU of 1442, not 1500. Docker does not know about the tunnel, so its networks default to 1500 and containers send packets the path cannot carry. When the signal that should make the sender shrink them is lost on the way back, connections stall with no error: a path MTU blackhole. Setting the daemon MTU was not enough, because each Compose network carries its own MTU, and Ansible will not recreate an existing network just because an option changed. I pinned 1442 on every Docker network and wrote a one-off playbook that compares each network’s MTU, and the MTU the API container actually sees on its interface, with the target, then rebuilds the network and recreates the containers wherever either is wrong.
Resizing a VM with a way back
When OpenStack Nova resizes a server, it waits in a VERIFY_RESIZE state where the change can still be reverted. My resize playbook only inspects unless I pass a flag and type the exact server and target flavor. On production it takes and verifies a PostgreSQL backup, stops the stack, resizes, and grows the ext4 filesystem only if the disk actually grew. Then it starts everything and checks the API health, every Celery worker on its own queue, and that the release manifest has the same checksum as before. Only then does it confirm. Any failure on the way reverts the resize while the window is still open, and the run still fails. If the cloud skips VERIFY_RESIZE and confirms on its own, the playbook stops before touching the filesystem, because there would be no way back.
Alerts from logs without the noise
Error logs make bad alerts if every line pages someone. An Icinga2 check I wrote reads ERROR and CRITICAL events from Loki and groups them by a fingerprint of application, logger, exception and message, so copies of the same failure become one problem. An incident opens at three related errors and clears only when they drop to one, so a steady leak in between holds the alert instead of re-notifying on every check. The hardest bug was in my first version of the query: it paged forward from the oldest line, so with more than one page of errors it reread the oldest page forever and reported nothing new during the very incident it existed to catch. It now walks backwards from the present and reports when results are truncated.
Edge firewall
- An OpenResty proxy fronts every public and private site, with TLS certificates issued automatically through Cloudflare DNS-01.
- On every public site it runs a web application firewall I wrote from scratch in Lua. It evaluates JSON rules against each request and blocks scanner paths, malicious user agents and abusive IPs before anything reaches an app. A rule can carry an expiry, so a temporary block lifts itself.
- Each worker checks the rules file every ten seconds and reloads when its content changes, so new rules go live without a restart. A file that fails to parse or validate is logged and ignored, and the last good rules keep running.
- A Python CLI (Typer, Pydantic, Rich) lists, shows, validates, tests and applies rules. Test replays a sample request against the ruleset, and apply refuses any rule that would block the address of my own SSH session.
- If an IP block goes wrong, one panic command clears every IP-based rule at once and keeps the path and user-agent rules in place.
- Every decision is logged in a structured form and shipped to the central logs, so I can see exactly what was stopped and why.
Private network
- Internal tools run on Headscale, a self-hosted Tailscale-compatible WireGuard mesh, fronted by the OpenResty proxy.
- Grafana, Graylog, Loki, pgAdmin and the OpenStack dashboard are only reachable over the mesh, and so is traffic from BABIS to the inference gateway.
- The internal hostnames resolve only through the mesh’s own DNS, and the proxy writes separate access logs for mesh and public traffic.
- Servers accept SSH only from members of the bastion’s security group, not from a whole subnet. The bastion takes keys only and allows no root login, admins need their password for sudo, and automation and deploys run as separate users.
- Security groups are declared in Ansible, and rules that are too broad, like the old subnet-wide SSH access, are listed and removed by name on every run.
Backup and restore
- Scheduled PostgreSQL dumps are compressed, checked with pg_restore --list and given SHA-256 checksums, then copied to a central store on the bastion and checked again on arrival.
- Each successful backup writes a marker that monitoring watches, so a dump that stops running raises an alert.
- A restore CLI I wrote lists backups by environment, database, date and hour and verifies their checksums before anything is restored.
- Restores take a safety dump first and support a dry run. The zero-downtime mode restores into a side database and swaps it in with a rename. Every run writes a log tagged with the operator, and production asks you to type the environment name.
- For an audit, I restored the production database into the Odyssey QA environment in 19 seconds, checked row for row.
Release pipelines
- Azure DevOps pipelines release all three products, built on self-hosted build agents and pushed to a private Docker registry.
- A release names exact image versions and latest is never deployable. The inference gateway goes further and accepts only images pinned by digest.
- A Python deploy runner I wrote for each product runs database migrations as a gate before any live container changes.
- Version state is swapped atomically, and if health checks fail, the previous version comes back automatically.
How it runs
- Ansible runs from the bastion, which is also the Icinga2 master and the central backup store.
- Icinga2 agents run on every VM and on the hypervisor, with custom Python probes I wrote for memory and CPU pressure, disk I/O, network retransmits, container resource limits, required containers and systemd units, Celery workers and queues, the OpenStack control plane and the hypervisor’s RAID.
- What each host must run is data: a global baseline, plus its group, plus host additions, minus host exclusions, rendered into one policy file that every probe reads.
- Central checks cover HTTP health, TLS certificates 30 days before they expire, and backup freshness.
- Alerts arrive in Microsoft Teams as Adaptive Cards, with a button that opens the matching request in Graylog.