---
title: "Preview Environments using Neon, Kubernetes, and Argo CD"
description: "Per-pull-request preview environments can be built by pairing Neon's copy-on-write Postgres branches with an Argo CD ApplicationSet using the pullRequest generator, which deploys a Helm chart into a namespace per PR."
url: "https://swe.quest/articles/preview-environments-using-neon-kubernetes-and-argo-cd-10c042240d5ec5fe"
canonical: "https://neon.com/blog/preview-environments-neon-kubernetes-argo-cd"
source: "Neon"
published: "2023-11-28"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["deployment","kubernetes","ci-cd","postgres","infrastructure-as-code"]
---

# Preview Environments using Neon, Kubernetes, and Argo CD

A post on [Neon](https://swe.quest/sources/neon.md), published 2023-11-28, 9 min read, How-to. Original: [https://neon.com/blog/preview-environments-neon-kubernetes-argo-cd](https://neon.com/blog/preview-environments-neon-kubernetes-argo-cd)

## Summary

Per-pull-request preview environments can be built by pairing Neon's copy-on-write Postgres branches with an Argo CD ApplicationSet using the pullRequest generator, which deploys a Helm chart into a namespace per PR. A GitHub Actions workflow builds and pushes the container image, creates a Neon branch and compute via create-branch-action, then uses the argocd CLI to set the database URL and image tag on the PR's Application. It also comments the preview URL on the PR. Setting these parameters imperatively departs from strict GitOps but is a pragmatic tradeoff when values aren't known ahead of time.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)
- [Kubernetes](https://swe.quest/tags/kubernetes.md) (Infrastructure)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Infrastructure as code](https://swe.quest/tags/infrastructure-as-code.md) (Infrastructure)

## Prerequisites

- Kubernetes basics ([easy posts on Kubernetes](https://swe.quest/tags/kubernetes.md?difficulty=easy))
- GitHub Actions workflows ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))
- Argo CD and GitOps ([easy posts on Infrastructure as code](https://swe.quest/tags/infrastructure-as-code.md?difficulty=easy))
- Postgres connection strings ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

Neon, Argo CD, ApplicationSet, GitHub Actions, Kubernetes, Prisma, Next.js, Helm

## Related posts

- [A database for every preview environment using Neon, GitHub Actions, and Vercel](https://swe.quest/articles/a-database-for-every-preview-environment-using-neon-github-actions-and-vercel-dd5fe24cba2d12b5.md): Neon · 2023-04-14 · Medium · 14 min read · PostgreSQL, CI/CD, Deployment, Schema migrations
  Neon's copy-on-write branching can give every pull request its own production-like Postgres database, avoiding the bottlenecks of shared staging or shared preview databases.
- [Fullstack preview environments using Neon and Qovery](https://swe.quest/articles/fullstack-preview-environments-using-neon-and-qovery-5ddb9f5e7c2f931c.md): Neon · 2023-08-11 · Medium · 8 min read · PostgreSQL, CI/CD, Deployment, Serverless
  Each Qovery preview environment can get its own isolated Postgres database by using a Qovery lifecycle job that creates a copy-on-write Neon branch on the environment's Start event and deletes it on Delete.
- [Behind Modem.dev’s Product Velocity](https://swe.quest/articles/behind-modem-dev-s-product-velocity-485adbdf853a0161.md): Neon · 2026-01-29 · Medium · 4 min read · PostgreSQL, Schema migrations, CI/CD, Developer productivity
  Modem, a startup building an AI agent that centralizes user feedback from Slack, Discord and GitHub, uses Neon Postgres branching as its development workflow.
- [A branch-first dev loop for Neon: link, checkout and env pull](https://swe.quest/articles/a-branch-first-dev-loop-for-neon-link-checkout-and-env-pull-3d4b71e97977636f.md): Neon · 2026-06-10 · Medium · 6 min read · Developer tools, PostgreSQL, AI for coding, Serverless
  Neon's CLI adds three commands for branch-first Postgres development. \`neon link\` binds a workspace to a project and branch via a git-ignored \`.neon\` file. \`neon checkout\` creates or switches database branches, much like \`git checkout -b\`. \`neon env pull\` writes only the Neon-managed connection strings and service secrets for the current branch into \`.env\`.
- [Branching Postgres databases with the Neon API](https://swe.quest/articles/branching-postgres-databases-with-the-neon-api-3faf0de941bc811a.md): Neon · 2022-12-07 · Medium · 3 min read · PostgreSQL, CI/CD, Testing
  Neon branches are copy-on-write clones of a Postgres database that can be created and deleted through the Neon API, giving CI pipelines an isolated copy of production data for end-to-end tests.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
