Deploying a Turborepo into Kubernetes
Thinking of Heroku or Render? This isn't that blog. This guide is for developers and DevOps engineers looking to deploy their Turborepo into custom Kubernetes environments like k8s or k3s.
So, you've built a TurboRepo with Next.js for the frontend and NestJS for the backend, and now you're wondering:
Integration Point | Shared Goal / Description | Quick Action |
Responsive Design | Ensures a seamless user experience across all devices, a critical baseline for modern sites. | Start mobile-first and test at multiple breakpoints (320–1440 px). |
Component-Based UI | Reusable components boost consistency and development speed. | Maintain shared component library |
Design Systems & Tokens | Centralizes colors, spacing, and typography, preventing style drift. | Sync design tokens between Figma/Sketch and CSS variables or Tailwind config. |
Accessibility | Broadens audience reach and ensures compliance. | Fix critical issues at each sprint. |
Performance Optimization | Directly impacts SEO, conversions & user satisfaction. | Optimize images, lazy load & non-critical asse |
"How the heck do I get this thing running on Kubernetes?"
Don’t worry you’re not alone.
Deploying microservices (or even monorepos) into Kubernetes can feel intimidating when you're just starting. Between YAML files, Docker images, namespaces, pods, services… it's easy to get lost.
In this blog, we're going to walk through exactly how to deploy your TurboRepo to Kubernetes, step by step without the fluff, without the overwhelm.
We'll cover everything you need - creating Docker images, defining Kubernetes deployments, setting up services, and applying them all to your cluster. If you're serious about taking control of your infrastructure or passionate about custom server deployment, this guide is for you.
🛠️Prerequisites
✔️A running Kubernetes cluster (k8s) or a lightweight alternative like k3s
✔️Docker images built and pushed for frontend and backend:
- apps/web (Next.js frontend)
- apps/api (NestJS backend)
If not already build, refer to: How to deploy a Turborepo (Next.js + NestJS) on Any Server using Docker
📂TurboRepo Structure
1apps/2web/ ← Next.js 15.2.1 (Frontend)3api/ ← NestJS 11.1.2 (Backend)4packages/ ← Shared libraries
Step 1: Create a Namespace for your app
Think of a namespace like a folder where your application and it's related stuffs lives. Let create one.
File: namespace.yaml
1apiVersion: v12kind: Namespace3metadata:4name: asynx-turborepo-tutorial5labels:6name: asynx-turborepo-tutorial
Step 2: Create Deployment for web (frontend)
File: web-deployment.yaml
1apiVersion: apps/v12kind: Deployment3metadata:4name: web-deployment5namespace: asynx-turborepo-tutorial6spec:7replicas: 28selector:9matchLabels:10app: web11template:12metadata:13labels:14app: web15spec:16containers:17- name: web18image: 192.168.0.103:5000/asynx-web-stage:latest #Replace your image URL here19ports:20- containerPort: 300021resources:22requests:23memory: "512Mi" #Adjust Minimum guaranteed memory for your web deployment24cpu: "500m" #Adjust Minimum guaranteed CPU for your web deployment25limits:26memory: "1Gi" #Adjust maximum memory that can be availed for your web deployment27cpu: "1000m" #Adjust maximum CPU that can be availed for your web deployment
Tested and working - feel free to copy paste, but always strive to understand the concept.
Step 3: Create deployment for api (Backend)
File: api-deployment.yaml
1apiVersion: apps/v12kind: Deployment3metadata:4name: api-deployment5namespace: asynx-turborepo-tutorial6spec:7replicas: 28selector:9matchLabels:10app: api11template:12metadata:13labels:14app: api15spec:16containers:17- name: api18image: 192.168.0.103:5000/asynx-api-stage:latest #Replace your image URL here19ports:20- containerPort: 300121resources:22requests:23memory: "512Mi" #Adjust Minimum guaranteed memory for your api deployment24cpu: "500m" #Adjust Minimum guaranteed CPU for your api deployment25limits:26memory: "1Gi" #Adjust maximum memory that can be availed for your api deployment27cpu: "1000m" #Adjust maximum CPU that can be availed for your api deployment
Tested and working - feel free to copy paste, but always strive to understand the concept.
Step 4: Create Services to Expose Deployment
Kubernetes deployments are like houses without doors. Let's give them entrances.
Web service (web-service.yaml)
1apiVersion: v12kind: Service3metadata:4name: web-service5namespace: asynx-turborepo-tutorial6spec:7selector:8app: web9ports:10- port: 300011targetPort: 300012nodePort: 3001913type: NodePort
API service (api-service.yaml)
1apiVersion: v12kind: Service3metadata:4name: api-service5namespace: asynx-turborepo-tutorial6spec:7selector:8app: api9ports:10- port: 300111targetPort: 300112nodePort: 3002013type: NodePort
💡 Tip: You can change nodePort values if you want different external ports, just make sure they’re within the 30000-32767 range.
Step 5: Apply Everything
1kubectl apply -f namespace.yaml2kubectl apply -f web-deployment.yaml3kubectl apply -f api-deployment.yaml4kubectl apply -f web-service.yaml5kubectl apply -f api-service.yaml
Step 6: Visit your App
If everything went well, go to:
- Frontend (Next.js): http://<your-server-ip>:30019
- Backend (NestJS): http://<your-server-ip>:30020
And just like that your TurboRepo monorepo is running in a kubernetes cluster.
✨Bonus Ideas
if you're feeling confident, here's what you could do next:
- Set up an Ingress controller for cleaner URLs like web.myapp.local and api.myapp.local
- Add ConfigMaps and Secrets for environment variables
- Hook it up with CI/CD (GitHub Actions + kubectl FTW)
Finally
Let's be real, Kubernetes is not easy. It's powerful and complex, but it comes with a learning curve that feel like a mountain at first. You'll spend hours debugging YAML, wondering why the deployment is not starting pods. figuring why the app is not reachable. That's normal.
So if you’re reading this and thinking “this is too much” don’t give up. Take breaks. Come back. Tinker. Try again.
This guide is intentionally basic and beginner-friendly, designed to get your TurboRepo running on Kubernetes with just the essentials