This is a boilerplate template for building / deploying a .NET Core Web API microservice on Kubernetes / Azure Container Instance. This leverages .NET 6, new hosting model, and new routing API to enhance .NET performance. You can learn .NET 6 more on ASP.NET Core minimal APIs.
GitHub Release | .NET Core Version | Diagnostics HealthChecks Version |
---|---|---|
main | 6.0.100-preview.6.21355.2 | 2.2.0 |
├── Controllers
│ └── KubeOpsController.cs
├── Dockerfile
├── KubernetesLocalProcessConfig.yaml
├── LICENSE
├── Models
│ └── DatabaseConfig.cs
├── Program.cs
├── Properties
│ └── launchSettings.json
├── README.md
├── Services
│ └── APIService.cs
├── Startup.cs
├── appsettings.Development.json
├── bin
│ └── Debug
├── configs
│ └── prod
├── dotnet-core-web-api.csproj
├── dotnet-core-web-api.sln
├── manifests
│ ├── deployment.yaml
│ └── service.yaml
Dockerfile
is .NET Core Web API Multistage Dockerfile (following Docker Best Practices)KubernetesLocalProcessConfig.yaml
is Bridge to Kubernetes config to supports developing .NET Core Web API microservice on Kubernetesconfigs
folder will contain .NET Core Web API centralized config structureappsettings.Development.json
is .NET Core Web API development environment configmanifests
folder will contain Kubernetes manifests (deployment, service)Startup.cs
is .NET Core Web API startup & path routing configProgram.cs
is .NET Core Web API environment variable mapping config
To setup this project, you need to clone the git repo
$ git clone https://github.com/kubeopsskills/dotnet-core-web-api.git
$ cd dotnet-core-web-api
followed by
$ dotnet restore
- .NET Core Web API Docker Image
Preparing Config Map for .NET Core Web API microservice
$ kubectl apply -k configs/prod
To deploy the microservice on Kubernetes, run following command:
$ kubectl apply -f manifests
This will deploy it on Kubernetes with the centralized config.
To deploy the microservice on ACI, run following command:
$ docker compose -f aci-docker-compose.yaml up -d
Deploying a .NET Core Web API microservice on AWS App Runner using AWS Copilot
To deploy the microservice on AWS, following these steps:
- Prepare AWS IAM roles and AWS ECR repository for the microservice
$ copilot init --app kubeops-demo
- Create the test environment on AWS
$ copilot env init --name test --app kubeops-demo
- Deploy the microservice on the test environment
$ copilot svc deploy --env test