Deployment to Kubernetes with Aspirate
Deploy your Aspire applications to Kubernetes with just 3 simple commands
The Aspire Roadblocks
After working extensively with .NET Aspire, I’ve identified three critical limitations:
❌ No Horizontal Scaling – You cannot scale from one service instance to multiple instances.
❌ Zero Resource Controls – No way to limit RAM or CPU usage per service.
❌ Visual Studio Dependency – Close Visual Studio, and your services die immediately.
New to .NET Aspire? Check out my .NET Aspire episode covering the control panel, observability features, and code-first development approach.
The Kubernetes Solution: Enter Aspirate
Deploy your Aspire applications to Kubernetes using the Aspirate tool:
- ✅ Horizontal scaling – Scale services independently
- ✅ Resource management – Set CPU and memory limits per service
- ✅ Persistent environments – No Visual Studio dependency
- ✅ Production readiness – Full Kubernetes orchestration
- ✅ Automatic YAML generation – No manual configuration
Three Magic Commands
Your entire deployment process becomes just three simple commands:
🚀 Complete Deployment Sequence
# 1. Initialize project configuration
aspirate init --non-interactive --container-registry "localhost:6000" --disable-secrets
# 2. Generate Kubernetes YAML files
aspirate generate --non-interactive --disable-secrets --include-dashboard --image-pull-policy "Always"
# 3. Deploy to your cluster
aspirate apply --non-interactive --disable-secrets --kube-context "docker-desktop"
That’s it! These commands automatically:
- Generate all necessary Kubernetes manifests
- Create deployments, services, and config maps
- Deploy everything to your cluster
- Handle networking and port forwarding
Step-by-Step Implementation
Prerequisites
- A working .NET Aspire application
- Kubernetes cluster (local or cloud)
- Docker registry access
1. Prepare Your Aspire Application
Modify your AppHost for Kubernetes compatibility:
// Configure OTLP endpoint for secure dashboard
builder.AddProject<Projects.WebApp>("webapp")
.WithEnvironment("OTEL_EXPORTER_OTLP_ENDPOINT", "https://dashboard:18888");
// Add environment variables for Kubernetes
builder.AddEnvironment("ASPNETCORE_ENVIRONMENT", "Production");
// Disable identity service for simplified deployment
// builder.AddProject<Projects.IdentityService>("identity");
2. Set Up Local Docker Registry
First, create a local Docker registry:
docker run -d -p 6000:5000 --name local-registry registry:2
3. Install Aspirate Tool
Install the Aspirate tool globally:
dotnet tool install -g aspirate
Verify Your Deployment
Check that everything is running:
kubectl get services
Access Your Applications
Set up port forwarding for local access:
kubectl port-forward service/webapp 8080:8080
kubectl port-forward service/aspire-dashboard 18888:18888
You should see:
- Web application at
localhost:8080
- Aspire dashboard at
localhost:18888
- All services running with scaling capabilities
Clean Up Deployment
When you’re done testing, clean up your deployment:
aspirate destroy --non-interactive --kube-context "docker-desktop"
What You’ve Achieved
✅ Independent Service Scaling – Scale each microservice independently based on load.
✅ Resource Management – Set specific CPU and memory limits for each service.
✅ Production-Ready Environment – Runs persistently without Visual Studio dependency.
✅ Automated Configuration – Aspirate generates hundreds of lines of Kubernetes YAML automatically.
Resources & Code
All code examples and configurations are available in my GitHub repository:
IggyCloud/resources
Next Steps
This deployment sets the foundation for:
- Performance Testing – Stress test to find maximum throughput
- Observability – Comprehensive monitoring and alerting
- Scaling Optimization – Identify and eliminate bottlenecks
Watch the Full Tutorial
🎥 Watch Video Tutorial
Questions? Drop a comment below – I respond to every question!