简体   繁体   中英

How to Deploy Visual Studio 2019 Solution to Azure AKS

I developed a DDD based modeling tool that code-generates.Net Core 3.x Web API services as separate projects within a single VS 2019 solution. My modeling tool allows me to quickly capture business domains and from there, generate as many domain services as is necessary to satisfy each business domain.

I created a test domain that creates three.Net Core Web API services (microservices) that I have been deploying and debugging within Docker for Windows, which worked great. To do this I added a docker-compose file into the generated VS 2019 solution folder and as such I am able to run and debug all services by selecting the Docker Compose debug option. Works like a charm!

Now I would like to deploy my entire solution into Azure AKS as a whole. I have created an AKS instance and enabled Azure Dev Spaces.

From within VS 2019 I have added Container support for Kube.nettes for each Web API project which created a chart folder in each Web API project folder. Note: I did not edit any file within the chart folder.

I created an azure dev space for my first API service and then ran AZDS Prep and then AZDS UP which ran through all 29 steps and successfully built the container image followed by the message Waiting for container...
followed by Service 'api' port 80 (http) is available via port forwarding at http://localhost:58512 .
Press Ctrl+C to detach

Followed by Unhandled exception when my service attempted to connect to EventStore. This made perfect sense as I have not added EventStore to my AKS Cluster.

So it would seem that I have to run this AZDS Prep and up on each API service which seems pretty task intensive as doing this step one service at a time could work for this simple example, but would not be practical when I have many more web api projects (microservices).

I feel that I should utilize Azure Dev Ops CI/CD to handle all of this per each microservice but I can't find any tutorial which shows me how to set this up from a VS2019 solutions perspective.

All examples I have found seem to be based on a single Web or Web API project being deployed to AKS but not based upon a solution with multiple Web API projects and which have dependencies on 3rd party images/containers.

I would like a tutorial that shows me how to deploy my entire Repo's worth of services including any dependencies (such as EventStore in my case) into AKS which does not require me to become an Helm expert, perhaps some tooling that can utilize the docker compose file.

Please let me know if you are aware of some tutorials out there that can show me how to set this up.

You do not need to deploy everything to your cluster all at once. With DevSpaces, the root space would contain a stable version of all of your microservices. You would attach your local dev environment to a child space when you want to work on a given service.

Automated releases to the root dev space would look something like this:

  1. Set up an Azure DevOps pipeline that will build and push all of the projects in your solution to Azure Container Registry. You will need multiple buildAndPush tasks , one for each container your solution generates. Give your container images unique tags (I like build ID concatenated with commit hash).
  2. Use kompose to translate your docker-compose.yml to kube.netes resource definitons yaml files. You may need to fine tune the output, adding some templating for image tags, etc. Add the output to your repo.
  3. Extend the AzDO pipeline from step 1 to apply the k8s yaml files to your AKS cluster using kubectl apply task(s) .
  4. If you want to only build and deploy a microservice that has changed on a given commit, you need to split your k8s yaml files out per project and use path filters on your pipeline triggers

I would provision the EventStore service separately from my code build & deploy pipelines - typically shared services like EventStore would be live before and after any dependent services. You can automate this through another pipeline if you want. There are some guides available for deploying EventStore to AKS - please note that, at present, it is not a recommended configuration .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM