Interview Prep/Real-World Interview/Multi-env and multi-account

Developers want a preview environment for every pull request. How would you build it?

AdvancedScenarioMulti-env and multi-account
Answer

Situation read → Previews speed up review, but without automatic cleanup and cost limits they become hundreds of forgotten environments.

What I'd do →

  1. One namespace per PR in a shared non-prod cluster, created by an Argo CD ApplicationSet with the pull request generator.
generators:
  - pullRequest:
      github:
        owner: acme
        repo: shop
        labels: ["preview"]
      requeueAfterSeconds: 300
template:
  metadata:
    name: 'shop-pr-{{number}}'
  spec:
    destination:
      namespace: 'pr-{{number}}'
  1. Each preview gets a hostname like pr-123.preview.acme.dev via wildcard DNS and a wildcard certificate.
  2. Dependencies: lightweight in-namespace databases with seed data, or shared staging backends for heavy services.
  3. Lifecycle: deleted automatically when the PR closes (the generator removes the Application), and a TTL for stale ones.
  4. Limits: ResourceQuota per namespace, Spot nodes, and scale to zero after inactivity.

Why → The pull request generator ties the environment's lifetime to the PR, so cleanup is automatic.

Interview tip → Lead with cleanup and cost; that's where preview environments usually fail.

All Real-World Interview questions Roadmap: Interview readiness

More on Multi-env and multi-account