Skip to content

Development

Stephanie M edited this page Sep 30, 2021 · 5 revisions

.NET Web Api - Part Two of the Tutorial

As a reminder, .NET Web Api's use several different pieces to function.

  • Controllers: This deals with routing and with the help of ASP.NET help in performing and returning various data from HTTP endpoints.
  • Models: These are used to describe data accessed in the database. The models help to keep data abstracted.
  • Data Transfer Object (DTOs): These also help with the abstraction of internal data from external view/access. These representations are what is sent out as opposed to the Models directly.

To connect the DTOs and the Models, instead of doing it the long way and manually connecting them, the AutoMapper package helped to simplify this process immensely! The biggest thing to keep in mind when using AutoMapper is that it's mapping from the Source -> Target. We create mapping profiles, and then utilize AutoMapper to create maps. To see this implementation see the source code in Profiles > PlatformsProfile.cs

Database information

Another unique feature of this project that was new to me is the use of InMemory database creation through the use of basically a script that checks whether there's data in memory and creates it if there is none. The implementation for this is in the source code > Data > PrebDB.cs

Docker - Part Three of the Tutorial

Docker requires a specific file to dockerize the app. The setup of this file is very specific and for this particular project is quite similar to the sample at this link: https://docs.docker.com/samples/dotnetcore/. The Docker commands used to starting, stopping, etc. are well described in the tutorial video this project closely follows.

Kubernetes - Part Three of the Tutorial

Also known as K8S, has files written in .yaml format which are whitespace sensitive. If new to the technology as I am, it's best to check out the tutorial as it does an excellent job of explaining at least the minimum amount of knowledge required to use K8S, and clearly walks through the creation of required files.

At this point, we created a second service and set up a simple local communication channel through the cluster IP (the second part of the depl files in the K8S branch). We've also set up an appsettings.Production.json file within PlatformService project that will direct Kubernetes where to look for the communication channel once re-deployed (because we'll have no control over the port number there). For production you'd preferably extract these settings as opposed to completely re-deploying in this way.

Updating K8S - Part Four of the Tutorial

After pushing and building the new Dockerized CommandService, we needed to restart the Kubernetes deployment. Once it's restarted there, we'll need to properly set up a proper API Gateway.

Clone this wiki locally