项目作者: kubeopsskills

项目描述 :
.NET Core Web API Starter Project
高级语言: C#
项目地址: git://github.com/kubeopsskills/dotnet-core-web-api.git
创建时间: 2020-11-07T05:29:33Z
项目社区:https://github.com/kubeopsskills/dotnet-core-web-api

开源协议:MIT License

下载


Develop on Okteto

.NET Core Web API Starter Project

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 Version Diagnostics HealthChecks Version
main 6.0.100-preview.6.21355.2 2.2.0

Project Structure

  1. ├── Controllers
  2. └── KubeOpsController.cs
  3. ├── Dockerfile
  4. ├── KubernetesLocalProcessConfig.yaml
  5. ├── LICENSE
  6. ├── Models
  7. └── DatabaseConfig.cs
  8. ├── Program.cs
  9. ├── Properties
  10. └── launchSettings.json
  11. ├── README.md
  12. ├── Services
  13. └── APIService.cs
  14. ├── Startup.cs
  15. ├── appsettings.Development.json
  16. ├── bin
  17. └── Debug
  18. ├── configs
  19. └── prod
  20. ├── dotnet-core-web-api.csproj
  21. ├── dotnet-core-web-api.sln
  22. ├── manifests
  23. ├── deployment.yaml
  24. └── 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

  1. $ git clone https://github.com/kubeopsskills/dotnet-core-web-api.git
  2. $ cd dotnet-core-web-api

followed by

  1. $ 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

  1. $ kubectl apply -k configs/prod

To deploy the microservice on Kubernetes, run following command:

  1. $ 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:

  1. $ 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
  1. $ copilot init --app kubeops-demo
  • Create the test environment on AWS
  1. $ copilot env init --name test --app kubeops-demo
  • Deploy the microservice on the test environment
  1. $ copilot svc deploy --env test

Learning Resources: