<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/building-kubernetes-pr-previews-with-shared-pulumi-components-2bshqcreu" -->

---
title: Building Kubernetes PR Previews with Shared Pulumi...
description: A team running a Kubernetes microservices app describes how they build ephemeral PR preview environments using a shared Pulumi component resource also used for...
canonical: https://daily.dev/posts/building-kubernetes-pr-previews-with-shared-pulumi-components-2bshqcreu
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Building Kubernetes PR Previews with Shared Pulumi Components | daily.dev
og:description: A team running a Kubernetes microservices app describes how they build ephemeral PR preview environments using a shared Pulumi component resource also used for...
og:url: https://daily.dev/posts/building-kubernetes-pr-previews-with-shared-pulumi-components-2bshqcreu
og:image: https://api.daily.dev/og/posts/2BsHQcREu.png
og:image:alt: Building Kubernetes PR Previews with Shared Pulumi Components
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building Kubernetes PR Previews with Shared Pulumi Components

**[Pulumi](https://daily.dev/sources/pulumi)** · 7 min read · 0 upvotes · 0 comments

## Summary

A team running a Kubernetes microservices app describes how they build ephemeral PR preview environments using a shared Pulumi component resource also used for their Dev, Stage, and Prod stacks. Each PR gets its own namespace and Pulumi stack, created and updated via CI as commits land, and torn down via a scheduled reconciliation job when the PR closes. The piece includes example Python code defining the StackInstance and K8Instance components, details on serializing stack updates to avoid conflicts, handling cleanup failures and infrastructure drift, and reports that environments become ready in about four minutes.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.pulumi.com/blog/building-kubernetes-pr-previews-with-shared-pulumi-components>

## Questions this post answers

### How can I create ephemeral PR preview environments on Kubernetes using Pulumi?

Define a shared Pulumi component resource (such as a StackInstance) that creates a namespace and shared resources like an image pull secret, then use a second component (K8Instance) per microservice for Deployment, Service, and Ingress. CI creates a new stack per PR, runs pulumi up on commits, and a scheduled job destroys the stack with pulumi destroy plus pulumi stack rm once the PR closes.

_Explore more patterns like this on daily.dev when designing reusable infrastructure for ephemeral environments._

### How do you avoid Pulumi stack operation conflicts when multiple commits are pushed to the same pull request quickly?

Serialize updates to each PR's Pulumi stack so only one update runs at a time, while still letting different PR stacks update in parallel. Before starting a new update, check whether an active operation is already running on that stack, since interrupted CI jobs can otherwise collide and cause stack operation conflicts.

_Developers tuning CI pipelines for Pulumi or similar tools can find related discussions on daily.dev._

### How long does it take for a Pulumi-managed Kubernetes PR preview environment to become reachable?

It takes about four minutes on average from the start of pulumi up until the preview environment is ready and reachable at its preview URL. This includes deploying Kubernetes resources, waiting for the application to become ready, and configuring routing, excluding the container image build time which happens beforehand.

_daily.dev surfaces real-world benchmarks like this for teams evaluating preview environment tooling._

## Similar posts on daily.dev

- [Build an EKS Environment Factory with Pulumi and vCluster](https://daily.dev/posts/build-an-eks-environment-factory-with-pulumi-and-vcluster-knxgztboc) · Pulumi · 0 upvotes · 1 comments
- [Managing Infrastructure: Everything Is a Pull Request](https://daily.dev/posts/managing-infrastructure-everything-is-a-pull-request-uxcw0owxg) · Medium · 0 upvotes · 0 comments
- [Cloud native application challenges: installing the walking skeleton](https://daily.dev/posts/cloud-native-application-challenges-installing-the-walking-skeleton-ew7cvjwvj) · The New Stack · 1 upvotes · 0 comments
- [Beyond YAML in Kubernetes: The 2026 Automation Era](https://daily.dev/posts/beyond-yaml-in-kubernetes-the-2026-automation-era-0a0hgzsbj) · Pulumi · 5 upvotes · 0 comments
- [A Guide to Preview Deployments with Serverless CI/CD](https://daily.dev/posts/a-guide-to-preview-deployments-with-serverless-ci-cd-31r49dgys) · Serverless · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#kubernetes](https://daily.dev/tags/kubernetes), [#cicd](https://daily.dev/tags/cicd), [#iac](https://daily.dev/tags/iac), [#pulumi](https://daily.dev/tags/pulumi)

[View this post on daily.dev](https://daily.dev/posts/building-kubernetes-pr-previews-with-shared-pulumi-components-2bshqcreu)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Building Kubernetes PR Previews with Shared Pulumi Components","url":"https://daily.dev/posts/building-kubernetes-pr-previews-with-shared-pulumi-components-2bshqcreu","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/building-kubernetes-pr-previews-with-shared-pulumi-components-2bshqcreu"},"datePublished":"2026-10-02T12:45:22.083Z","dateModified":"2026-10-02T12:45:43.531Z","description":"A team running a Kubernetes microservices app describes how they build ephemeral PR preview environments using a shared Pulumi component resource also used for...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c8d61a334f7702ff05234bb1f4723539?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c8d61a334f7702ff05234bb1f4723539?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Pulumi","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Pulumi","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/9792c211dccf434c8b469efac5b7b2ec","url":"https://daily.dev/sources/pulumi"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/building-kubernetes-pr-previews-with-shared-pulumi-components-2bshqcreu","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,kubernetes,cicd,iac,pulumi","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Pulumi","item":"https://daily.dev/sources/pulumi"},{"@type":"ListItem","position":3,"name":"Building Kubernetes PR Previews with Shared Pulumi Components"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/building-kubernetes-pr-previews-with-shared-pulumi-components-2bshqcreu#faq","mainEntity":[{"@type":"Question","name":"How can I create ephemeral PR preview environments on Kubernetes using Pulumi?","acceptedAnswer":{"@type":"Answer","text":"Define a shared Pulumi component resource (such as a StackInstance) that creates a namespace and shared resources like an image pull secret, then use a second component (K8Instance) per microservice for Deployment, Service, and Ingress. CI creates a new stack per PR, runs pulumi up on commits, and a scheduled job destroys the stack with pulumi destroy plus pulumi stack rm once the PR closes. Explore more patterns like this on daily.dev when designing reusable infrastructure for ephemeral environments."}},{"@type":"Question","name":"How do you avoid Pulumi stack operation conflicts when multiple commits are pushed to the same pull request quickly?","acceptedAnswer":{"@type":"Answer","text":"Serialize updates to each PR's Pulumi stack so only one update runs at a time, while still letting different PR stacks update in parallel. Before starting a new update, check whether an active operation is already running on that stack, since interrupted CI jobs can otherwise collide and cause stack operation conflicts. Developers tuning CI pipelines for Pulumi or similar tools can find related discussions on daily.dev."}},{"@type":"Question","name":"How long does it take for a Pulumi-managed Kubernetes PR preview environment to become reachable?","acceptedAnswer":{"@type":"Answer","text":"It takes about four minutes on average from the start of pulumi up until the preview environment is ready and reachable at its preview URL. This includes deploying Kubernetes resources, waiting for the application to become ready, and configuring routing, excluding the container image build time which happens beforehand. daily.dev surfaces real-world benchmarks like this for teams evaluating preview environment tooling."}}]}
```

