Next.js Kubernetes Deployment
This skill containerizes and deploys Next.js applications to Kubernetes. It generates a production-optimized multi-stage Dockerfile, Kubernetes Deployment/Service/Ingress manifests, and verifies the rollout — turning a Next.js codebase into a running Kubernetes service without manual YAML authoring.
Use this skill when you need to move a Next.js app from local development to a Kubernetes cluster.
Quick Start
# Deploy the Next.js app in the current directory
/nextjs-k8s-deploy namespace=frontend replicas=2 image_tag=v1.0.0
# Output files:
# - Dockerfile (multi-stage)
# - k8s/deployment.yaml
# - k8s/service.yaml
# - k8s/ingress.yaml
# Apply to cluster
kubectl apply -f k8s/
kubectl rollout status deployment/nextjs-app -n frontend
Key Features
- Generates a multi-stage Dockerfile optimized for Next.js (build + slim runtime stage)
- Produces Kubernetes
Deploymentmanifest with configurable replicas and resource limits - Produces
Service(ClusterIP/LoadBalancer) andIngressmanifests - Applies manifests via
kubectl applyand verifies pod readiness - Supports standalone output mode (
output: 'standalone'innext.config.js) for smallest image size
Process
- Generate a production-ready Dockerfile
- Create Kubernetes manifests (Deployment, Service, Ingress)
- Apply the manifests to the cluster
- Verify deployment status before finishing
The deployment process is handled by supporting scripts that create and apply all manifests.
When NOT to Use This Skill
- Static export sites — use
docusaurus-deployor a CDN; a running Node.js container is unnecessary for pure static output - Vercel / Netlify deployments — those platforms handle containerization automatically; Kubernetes adds unneeded complexity
- Frontend feature work — this skill only handles infra; use
nextjs-ui-builderfor building UI components
Common Mistakes
- Not setting
output: 'standalone'innext.config.js— results in a bloated image that copies allnode_modulesinstead of just required files - Forgetting to set
NEXT_PUBLIC_*environment variables at build time — these are baked into the bundle, not runtime-injectable - Using
imagePullPolicy: Alwayswithout a registry — causesErrImagePullon nodes that can't reach Docker Hub