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

Comic about preview environment: Kai's change waits in line for the one shared test server; each change now gets its own automatic live copy at pr-123.preview.example.com; Noor opens the link and finds a coupon error in checkout before it ships; after merge the copy is deleted, unused copies expire after 48 hours, and change #124 gets its own at pr-124.preview.example.com.