Close
AlgoliaLogoLight
Close full mode
logo

Template for Deploying a .NET Core Web API microservice on Kubernetes and ACI

Git RepositoryEdit on Github

Original Author: Sirinat Paphatsirinatthi Source Code: https://github.com/kubeopsskills/dotnet-core-web-api

The aim of this project is to simplify Kubernetes configuration.

This is a boilerplate template for building / deploying a .NET Core Web API microservice on Kubernetes / Azure Container Instance

.NET Core Web API Starter Project

Develop on Okteto

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.

Versioning

GitHub Release.NET Core VersionDiagnostics HealthChecks Version
main6.0.100-preview.6.21355.22.2.0

Project Structure

├── 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 Kubernetes
  • configs folder will contain .NET Core Web API centralized config structure
  • appsettings.Development.json is .NET Core Web API development environment config
  • manifests folder will contain Kubernetes manifests (deployment, service)
  • Startup.cs is .NET Core Web API startup & path routing config
  • Program.cs is .NET Core Web API environment variable mapping config

Setting Up

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

Deploying a .NET Core Web API microservice on Kubernetes

Prerequisite:

  • .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.

Deploying a .NET Core Web API microservice on Azure Container Instance (ACI)

Prerequisite:

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

Prerequisite:

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

Learning Resources:

Loading comments...