Hi all, I hope every one of you has used something like this: when you give Vercel, Netlify or any other such service access to your GitHub repo, they will watch your PRs and give you a preview for that PR so you can view your changes on a deployed version, not just code. This simple feature is called previews on most of the platforms.

Why? Because I want to learn a bit more about k8s and build scale-to-zero autoscaling with KEDA.

Why OwnPreview? If you know, my friends and I previously built a project called OwnDB, and the principle is the same - you self-host the solution to manage something for you. This time it’s your preview environments, that’s why I decided to keep it OwnPreview.

What’s The Plan?

The basic plan

As you can see, the plan is to keep it simple. For every PR there will be a webhook triggered for the control plane. Then the control plane will take action, like building a container image or deploying the image on the cluster.

I would also implement a way where people can directly build the image in GitHub Actions and just use OwnPreview to manage deployments. This is what PullPreview does. In fact, they do everything from your GH Actions. While I initially considered doing the same, having a dedicated control plane unlocks opportunities to add more features.

So my plan is to build it first such that the control plane is outside of the CI pipeline and then later build a CLI as well so everything can be done from anywhere.

Tech Stack

Go and client-go: Instead of writing bash scripts that wrap kubectl, I want the control plane to interact directly with the Kubernetes API. Go is the native language of K8s, making it the perfect fit for writing robust controllers.

BuildKit: Building container images inside a container is notoriously tricky. To do Docker-in-Docker requires a privileged container, which is a security risk. BuildKit is what Docker uses as the builder backend and lets us build inside a container without a privileged container.

KEDA: KEDA is the standard in K8s for event-driven autoscaling. One of the primary things in my head was to scale-to-zero to save resources when the preview is not required.

Difficult Road Ahead

Concurrency: What if a user pushes 3 commits to a PR in 2 minutes? (This is very possible in today’s agentic era). We need to cancel all the previous jobs and only run the latest one.

Cold Start: Scaling from 0 to 1 with KEDA will introduce unavoidable latency on the first HTTP request. Handling this gracefully is crucial for the user experience.

What’s Next?

I’m planning to blog the process and share all my learnings through these posts.

In Part 1, I’ll dive into unprivileged container image building using BuildKit.

If you want to keep up with the progress of the project you can take a look at the OwnPreview repo and find me on X or LinkedIn.