Services

Resources

Company

/

Preview environment

Preview environment

A preview environment, also called an ephemeral environment, is a temporary deployment of an application built from one pull request. Reviewers, testers and product managers can use the running change at its own URL before it merges. The environment is created automatically when the pull request opens and deleted when it closes or sits idle.

How it works

CI builds images for the pull request branch. A controller, such as an Argo CD ApplicationSet with a pull request generator, deploys them into a dedicated Kubernetes namespace. For example, pull request 123 gets the namespace pr-123 and the URL pr-123.preview.example.com. The environment needs its own database with migrations and seed data. It may also need preview versions of dependent services. A cleanup job removes environments idle for more than a set period, such as 48 hours.

Why it matters in production

Preview environments remove the queue for one shared staging server and catch integration bugs before merge. They can get expensive if they are never cleaned up, so automatic teardown and cheaper capacity such as spot nodes matter.

See also

On the One2N blog

References

  1. Argo CD pull request generator

Timeline of a preview environment for pull request 123. The PR opens, CI builds images, and it deploys to namespace pr-123, reachable at pr-123.preview.example.com. Three lanes follow: if the PR merges, the environment is deleted when it closes; if it is left open, it sits idle for 48 hours and a cleanup job removes it; a red lane with no teardown keeps running and billing past the end of the timeline.

Putting this into practice?

Talk to One2N about our CI/CD services

Talk to One2N about our CI/CD services