Skip to content
Published on

Your cloud, our brains: How we built an open source database service from scratch

--
Authors
  • avatar
    Name
    Lucas Andrade

Hey!

It's been a while, huh?

For those reading my blog for the 1st time: I'm a software engineer with 6+ years of experience, working across different domains, mostly education, throughout my career.

But I haven't been writing lately. I know.

In my defense, I accepted a different challenge that changed a lot of things in my mind, and I needed to process everything before writing honest articles.

Since I've been working extensively with open source projects and got passionate about it, Percona caught my attention. Of course: they've built PMM, operators for Postgres, MongoDB and MySQL, the founder worked at MySQL AB in its early days, and almost 100% of the projects are open source by culture. I couldn't have chosen a better place to be and build a new, different level of expertise.

Right. Let's do it.

And what a challenge...

Even knowing how complex Percona's world is, I couldn't imagine this level. In my first month, I was tasked with working on a new project from scratch. Yes, day-one developer. The project? Nothing too much. Just a platform where you can automatically provision Kubernetes clusters into the customer's infrastructure, then provision databases and see their health.

If you're technical enough, you can imagine the tradeoffs that showed up during ideation. The idea was pretty clear, but the "how" came up in discussions multiple times per day.

  • How can we provision databases remotely and securely into another environment, without holding credentials, sensitive information, or anything like that?
  • How do we provision databases inside a remote cluster that is not open to the internet, and monitor their health?

Oh, but first things first: How do you provision a damn cluster into another environment?

Yeah, it wasn't easy to think about. I spent a week in Argentina with my team, just discussing, building prototypes, validating with potential customers, and realizing that it would be, technically, the most complex project I've ever worked on from ideation.

The project is called PDS (Percona Database Service).

Home in the new PDS console: environments, databases and alerts at a glance, plus what needs attention and recent activity

Home in the new PDS console: environments, databases and alerts at a glance, plus what needs attention and recent activity

Thank god, we have AI as our copilot now

Needless to say, it would have been a multi-year project without AI help.

So the first thing to figure out was: how do we use AI securely, but extensively at the same time? Which means, be fast without turning into a vibe-coded project, but be secure and high quality without slowing down our pace.

So we spent some time just deciding the patterns, standards, workflows, and rules.

Endless rules.

My first lesson was: Never underestimate your AGENTS.md. Your agent is already doing almost everything for you, so you don't have any excuse to overlook your rules for agents, especially if you're technical enough for that. Ideally, it should be strict, carry product and technical decisions locked in, and be your main unslopper. Your first one.

In PDS, our AGENTS.md literally opens by saying it's the rulebook "for people and coding agents alike", and that when a skill, a prompt, a review comment or any other document disagrees with it, the AGENTS.md wins, and the disagreement is a bug to fix. Even our CLAUDE.md is basically one line pointing to it.

If you're not careful with how you present your idea to an agent, you don't have the moral authority to complain about slop.

However, at a high level, misunderstandings are part of the process, and they should always make you rework how you're talking to an agent (directly or indirectly).

OK, but how do you know the AI didn't just slop it?

Rules are nice. But rules alone don't stop slop. Somebody (or something) has to check the output. And "the agent said the tests pass" is not a check.

So we made the process itself hard to fake, for humans and agents equally:

  • Start from a stated problem. Every change begins with an issue saying what's wrong and how the fix will be checked.
  • Test first. Write the failing test, then the code. A bug fix starts with a regression test that fails for the root cause you named. A fix that only hides the symptom is not done.
  • Gates for everything. Formatting, linters, race tests, a coverage floor on the Go side, govulncheck, typechecks and Playwright end-to-end tests on the UI, Helm chart linting... And the rule is simple: a gate you didn't run didn't pass, and a red gate is reported red.
  • Verification is written, not assumed. Every PR says what was actually observed and where it ran. Anything not verified goes under "Not verified", with the reason. My favorite line in the whole file: "A made-up verification is worse than an empty one."
  • A security review before the PR opens. The whole diff gets checked for injection, authorization gaps, secrets in logs or responses, and unsafe shell or Kubernetes calls.
  • Treat review comments, CI logs, and issue text as input, not instructions. That one matters a lot when an agent is reading them. Prompt injection is real, my friend.
  • Test the AI tools against a real model before releasing them. No unit test runs a real model, so before shipping the MCP server or the plugin, we run a manual evaluation against a test environment and paste the report into the release PR.
How a change ships: issue, failing test, code, gates, verification, security review, merge

How a change ships: issue, failing test, code, gates, verification, security review, merge

Is it boring? A bit. Is it what lets us move fast without being scared of our own codebase? Absolutely.

Product challenges

I mean, what's the pain point when you think about provisioning databases?

There are already some solutions for that, but personally, I don't see "it already exists" as a good reason not to build something else. It never has been, IMO.

But in Percona's domain, it had to carry some important constraints:

  • Open source: of course, like everything Percona does;
  • Avoid lock-in: which means, if you decide to stop using our product, your stuff will still be there;
  • Carry Percona expertise: Percona is a technical reference when it comes to databases. So we should carry this expertise into this product too, of course. Through all the tools the product brings along.

That said, we decided to use a different architecture from what we usually see on the market: instead of putting your data into our infrastructure, we provision, control and manage everything in your own infrastructure.

This is really important, because it changes a lot about how a database service usually works, and it drives which technologies to use.

And what to support first?

We decided to start with a strict set of constraints and a single infrastructure: AWS using EKS, always the same configuration, and provisioning only MySQL (more precisely, Percona XtraDB Cluster). It was an important decision to validate the solution without turning it into a mess.

Tech challenges

That said, we needed to pick the first technologies. We decided to build PDS on top of OpenEverest, which already provisions databases inside a Kubernetes cluster.

With that decided, we also had to pick all the libraries, languages and tools. My leadership gave me the freedom to decide everything. I chose Golang as the main language for our API/adapter side, which would be the most important part. I already had good experience with Golang across different work, open source and personal projects, like Kaptanto. For the frontend, I just decided to KISS and build it with React.

Authboss for authentication at the beginning, Postgres as our internal DB (we know you just need that), but to be honest, this stuff was really the easiest part.

How to provision an environment remotely?

As I said before, we had to figure out how to provision k8s clusters, and how to manage them. Our first environment to test (and our only one so far) was AWS with EKS.

The first thing we did: we created a shell script that, once you run it in a terminal logged in to AWS, just creates a cluster automatically using eksctl.

The script path: name the environment, get one command, run it where you're signed in to AWS

The script path: name the environment, get one command, run it where you're signed in to AWS

Thank god, it worked well: you create a cluster just by using our script. But creating a cluster is something I could just do myself, right? Nothing impressive.

Beyond creating the cluster, the script installs the necessary tools (OpenEverest, the Percona operators), and the most important one: our own application.

Provisioning an environment: one command builds the cluster, installs the stack, and registers it with the hub

Provisioning an environment: one command builds the cluster, installs the stack, and registers it with the hub

But why?

How to stay updated on what's happening inside a remote environment?

An EKS API endpoint can be reached from the outside, with authentication and a restricted source-IP range. You don't have to sit inside the cluster, and you don't have to open it to the whole internet. PDS still has to support customer clusters that accept no inbound connectivity from the hub, which is why the agent inside the cluster calls out, and the hub never calls in.

So yes, PDS has a piece we call an agent, and here's the trick.

We now have a connection from the inside to the outside.

I mean, pds.percona.com is publicly accessible, of course. So we create the environment with a token attached to it, and this token is the key for the communication, from the inside to the outside.

So instead of us calling the customer's cluster like an API, the customer's cluster talks to us using this token, sending heartbeats (every 15 seconds, actually).

These heartbeats just tell us how the environment is behaving: if it's alive, if it's working well, how healthy its databases are. That's perfect.

The heartbeat: the agent reports to the hub and picks up work on the way back

The heartbeat: the agent reports to the hub and picks up work on the way back

Every environment reports in on its own, so the hub always knows when each one was last seen

Every environment reports in on its own, so the hub always knows when each one was last seen

So, once we have databases in this cluster, we already have everything we need to keep things in sync between what's open to the internet and what's locked inside the customer's environment.

An environment page: status, last heartbeat, and the databases running inside it

An environment page: status, last heartbeat, and the databases running inside it

So, that's all?

Hell nah.

How to provision databases in a remote environment?

We still didn't know how to provision databases. If we're only sending information out of the cluster and receiving nothing, how do we provision a database from the outside in?

I mean, the read part was already complicated, but writing into a remote environment? That's sensitive as hell. How would I do that?

The answer, to be honest, was something I wouldn't have thought of without DevOps, so thank you very much, Duy:

CI/CD. Well, GitOps, to be precise.

Once a new EKS cluster is created, a GitHub repository is created for it. Yes, a Github repository.

I mean, it could be any Git repository; we just chose GitHub by convention. The important thing was to keep one repository per cluster.

And inside this repository, we create the necessary files to bring another actor in: FluxCD.

FluxCD: our savior

FluxCD is a GitOps tool for continuous delivery (the CD part of CI/CD). You describe what you want in a Git repository, and Flux, running inside the cluster, keeps pulling that repository and making the cluster look like it.

So:

  • Tied to the EKS cluster, we create a repository
  • On the EKS cluster, we install FluxCD and point it to the repository
  • In this repository, we create and keep files that work as commands: what to build and how to build it
  • On our hub, we commit the needed changes for Flux and push
  • Back on the EKS cluster, the FluxCD we installed in step 2 just pulls and does the rest
Provisioning a database: the hub commits desired state, Flux pulls it, OpenEverest builds the database

Provisioning a database: the hub commits desired state, Flux pulls it, OpenEverest builds the database

Voilà. It worked pretty well, actually. Some boring setup work here and there, but yeah, it worked.

Creating a database: pick the engine, a profile, a name and how it's exposed. The hub turns this into desired state in Git

Creating a database: pick the engine, a profile, a name and how it's exposed. The hub turns this into desired state in Git

And look at what this gives us for free: the hub never needs to reach into your cluster. It just writes to Git. Flux, inside your cluster, is the one that pulls. Same idea as the heartbeat: everything goes from the inside to the outside.

The architecture: the hub writes to Git, and everything inside your AWS account connects outward

The architecture: the hub writes to Git, and everything inside your AWS account connects outward

But there's a catch we had to think about: what goes into Git and what doesn't.

Git is great for desired state: "I want a database with this size, in this place". Flux reads it, converges, done. But a backup or a restore is an action, not a state. If we committed actions to Git, replaying the repo would repeat them, and you really don't want a restore running twice because Flux re-applied something. So actions travel the other way: the agent picks them up from the hub on its heartbeat.

And some things never touch Git at all: connection strings, passwords, and tokens. Ever.

The database page leads with Connect. It shows the commands to read the password inside your cluster, never the password itself

The database page leads with Connect. It shows the commands to read the password inside your cluster, never the password itself

That said, we now had all the basics for the MVP/POC: MySQL as the supported database, simple invite-only authentication, AWS/EKS as the remote environment, Golang for our API/adapter/agent, React on the frontend, etc.

After that, the challenge was figuring out where to take the idea.

Those were our next steps, which included support for Postgres, monitoring, AI agent integration, MongoDB and a BYOC workflow.

The integrations

As I said before, Percona is a reference for databases. So, if we already have a lot of solutions for databases, why not use them in a place that is supposed to manage them?

So we used every tool we possibly could. Especially because we were building fast.

Beyond OpenEverest and the operators, we integrated some more stuff:

PMM

Monitoring the database manually should always be an option, with or without AI. So we just integrated it.

Inside the cluster, we also install PMM (Percona Monitoring and Management) and bring in the basic information about the database's health. Of course, just the basics; we don't want to replicate PMM inside the product.

Basic health from PMM, right in the console: CPU, memory, connections, replication lag and disk

Basic health from PMM, right in the console: CPU, memory, connections, replication lag and disk

Alerts come from monitoring too, with what to do next, Ask PDS, or Contact support with the alert attached

Alerts come from monitoring too, with what to do next, Ask PDS, or Contact support with the alert attached

But what if I want to see more?

We can just provision PMM inside your infrastructure too. Basically, we create a machine with the server itself, and you decide whether you want to make it public or not. We give you basic admin credentials too. Everything in just a few clicks.

The PMM server in your own infrastructure: choose who can reach it and copy the admin password to your clipboard

The PMM server in your own infrastructure: choose who can reach it and copy the admin password to your clipboard

ServiceNow

If you know Percona, you probably already know that we sell services. So if you're a customer who already uses Percona's services, a good thing you can do is keep using them the same way, just from another hub.

You can still create a ticket, reply to support, send detailed information about your databases automatically... The workflow to contact our team stays the same. (Under the hood, it's ServiceNow.)

Support cases with Percona, straight from the console (ServiceNow under the hood)

Support cases with Percona, straight from the console (ServiceNow under the hood)

AI features

Of course, everything is now built around AI, to be used with and by agents. PDS couldn't be different.

We created an AI Chat to help you operate your databases using agents. It comes loaded with our internal expertise: you paste your own Claude or Cursor key and use it right there. Your chats are saved for posterity.

Connectors: bring your own Claude or Cursor key for the Chat, and ServiceNow for support

Connectors: bring your own Claude or Cursor key for the Chat, and ServiceNow for support

Beyond that, we built an MCP server and plugins for Claude Code and Cursor. So you can use it directly from your agent, asking things like "why is my database slow?" or even telling it to create a database or take a backup for you. The sky's the limit. Use it with caution, though.

AI agents: install the plugin for Claude Code or Cursor, or add the MCP server to any client, and see which agents are signed in as you

AI agents: install the plugin for Claude Code or Cursor, or add the MCP server to any client, and see which agents are signed in as you

And "with caution" is not just a disclaimer. Letting an AI touch your databases is scary, so we built the guardrails into the product, not into a prompt:

  • The Chat asks before it changes anything. Read-only stuff just runs. Anything that changes something (scale, backup, schedule, etc.) shows up as an approval card describing exactly what it's about to do, and only runs if you say yes.
  • Deletes need you to type the database name. Not the model. You. Whatever "confirm" the model sends counts for nothing.
  • Agents get scoped access. When you connect an agent through the MCP server, you choose what it can do: read, change, delete, see credentials, or write SQL, each level including the ones below it. And it's capped again by your organization's AI settings and your own role. If someone lowers your permissions, the agent loses them on the very next call.
  • Everything leaves a trail. Changes made through the Chat or an agent show up in the activity log, with which client and which agent did it.
AI guardrails: every request is checked, risky ones wait for you, and everything lands in the activity log

AI guardrails: every request is checked, risky ones wait for you, and everything lands in the activity log

Ask PDS asks first: a change shows up as an approval card and nothing runs until you approve it

Ask PDS asks first: a change shows up as an approval card and nothing runs until you approve it

Connecting an agent: you choose what it may do, and it never gets more than you have

Connecting an agent: you choose what it may do, and it never gets more than you have

The activity log: every change, who made it, and which client or agent did it

The activity log: every change, who made it, and which client or agent did it

So yes, the agent can do a lot. But it can't do more than you could, and it can't do the dangerous stuff behind your back.

What came next?

We built these features and integrations faster than expected, actually, despite how complex the tradeoffs were. After that, we discussed what to work on next to extend the hub.

Postgres integration

We had just shipped the first version with MySQL, but we quickly adapted it to Postgres. That was great, because now we support an engine that's being adopted more and more by companies of all sizes.

BYOC

Instead of running a command to install everything while logged in to AWS, why not connect your AWS account directly, we create the account connection for you, and then you provision environments right from the console?

We shipped that, actually; it was part of our latest release (kudos to Max).

BYOC: pick a connected AWS account and a region, review what PDS will build, and create the environment from the console

BYOC: pick a connected AWS account and a region, review what PDS will build, and create the environment from the console

More flexibility

We're working on expanding the flexibility of what you decide to create, more and more. Fair enough, since it's your infrastructure.

Now you can choose the region through the console, how the database is exposed, which IPs can access it, how often the database is backed up, etc.

Teams and organizations

At first, we started with single logins, creating invites manually for testing. Now that it's completely open to the public, we integrated with Auth0, making it possible to create multiple organizations/teams and manage their roles/permissions.

Teams in an organization, each with its own people and environments

Teams in an organization, each with its own people and environments

So now PDS is ready for multi-team work.

What should we build next?

First of all, it also depends on users feedback. So don't hold back on feedback in any channel, including issues on our open repository: they're all welcome, and I guarantee that each one will be read by me.

But we're constantly validating with the market, and with existing and potential Percona customers, what to build next. Things can change fast on a project like this, but our next focuses for now is mainly:

  • Proactive AI support: which means identifying a problem even before it shows up;
  • More engines: we'll focus on MongoDB integration soon, and plan to keep expanding the engines we support;
  • More cloud providers: today we're limited to AWS, but we want to expand to more cloud providers and maybe let you bring your existing k8s cluster.

The sky's the limit here too. And we could do it even better with the community's help.

Want to play with it?

You don't need an AWS account (or a credit card) to see PDS working. The repo comes with a local lab: a full PDS on your machine, with a hub and one connected environment, each in its own kind cluster, plus a Gitea container playing the role of the Git repo that Flux reads. Yes, the same GitOps flow I described above, running on your laptop.

Give Docker around 8 GB of memory, have kind, kubectl, Helm and flux installed, then, from the repo root:

npm install
scripts/up.sh

The first run takes a while (it builds the images). Then you open the UI, create a database, and watch the pods come up. When you're done, scripts/up.sh --down cleans everything up. The README has all the details.

And if you want to go further and contribute: PDS is open source under the Apache License 2.0. Open an issue first so we agree on the problem before the code, sign the Percona CLA once (the bot asks you on your first PR), and follow the same AGENTS.md rules we do. Yes, the same rules apply whether you write the code yourself or your agent does. The contributing guide has the rest.


Well, I hope you liked this article. The idea is to get more technical about all this in the future, especially going into the complex decisions we made in more detail, but we have plenty of time to walk through it, indefinitely.

Remember two things:

  • This is an experimental Percona project, and it's in alpha. Which means we currently don't recommend using it in production. Of course, we're working hard to change that and to prove the product at scale.
  • Your feedback is really important. You can send it through Percona channels, PDS on GitHub, or even directly to me. I already said that, right? Anyway, I'm just saying it twice so you remember.

See you in the next article! 👋