Re:Staging is dead: The rise of preview environments
by jcraft on Thursday December 22, 2022 @04:56PM
(#34099341)
We've seen customers do something very similar and we've helped them get privacy-safe data into each preview. Handwaving a lot here, but the steps are 1) anonymize production data to a destination, 2) snapshot the anonymized data, and 3) replicate the anonymized data to all of the previews.
We've been experimenting with a pretty reliable way to do this in-house, though. The key is that a single Kubernetes namespace per preview app iteration contains everything your preview app needs. We have a Github action, triggered by a "preview" label on a PR and any subsequent commits, that:
- builds and pushes a docker image with a dedicated tag
- within the specific preview namespace named after a, spins up and seeds with test data (in our case, a sanitized subset of production) a dedicated database statefulset
- runs the Helm chart that we use for production, but against this specific preview namespace, with this specific image tag, and overriding our normal ingress domain with one specific to this preview app
Then when the label is removed, we drop the namespace and reclaim all resources. "Rebasing" off later data, or if reviving a stale PR, is as simple as removing and re-adding the label.