Azure Kubernetes Service (AKS) with .NET : Part 3 - Deploying Applications

 

Deploying applications to AKS and AKS in general seems daunting at first, but my initial exploration into Kubernetes is slowly unraveling the mystery.   I now find the process of setting up AKS and deploying applications very straight-forward after working the process a few times.

I setup my AKS Cluster in my previous post Azure Kubernetes Service - Part 2 - Creating an AKS Cluster. This blog post is all about establishing the process for deploying a simple web application to AKS.   The purpose of this post is to understand the process and steps for deploying applications to AKS and not about automating the process.   I will save the automation for a later post.

1.  Create a simple web application  - I utilized one of the many examples out there and built a simple .NET Core API  using .NET MVC and C#.    This is a small API intended to represent an API used in a "Todo List" application.   This sample is available for download on my GitHub if you like  to see more...   I did enable Swagger in order to simplify the testing of the application.   The repository also contains a dockerfile used for containerization.

2. Build and Test Docker Image - I used a bash terminal in VS Code to execute the docker commands and this allows me to test the docker image.  The dockerfile is part of the source code.

  • docker build ./         
  • docker run ./
This step is totally optional and I personally like to do this to test the container locally before relying totally on testing in AKS.

3. Tag and push container to ACR - The Azure Container Registry is  a managed Docker repository in Azure.   Note that you must be logged into Azure to perform these commands.

  • docker tag ,/aksdemotodoapp <your-acr-name>.azurecr.io/aksdemotodoapp:v1
  • docker push <your-acr-name>.azurecr.io/aksdemotodoapp:v1
Your container is now in Azure and ready to be deployed to AKS.

4. Deploy the application to AKS - Use the "kubectl" command to execute the deployment script

  • kubectl apply -f deployment.yaml

That is all there is ... You can no test our container in AKS by hitting the endpoint and viewing the swagger screen.

Please check out my previous posts around my personal study to learn AKS....

Azure Kubernetes Service - Part 2 - Creating an AKS Cluster

Azure Kubernetes Service (AKS) with .NET : Getting Started