Services

Resources

Company

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

Four-panel comic explaining Preview environment. A preview environment is a short-lived, full copy of an application created for a single pull request and deleted when it is no longer needed.