ASP.NET Core apps in Kubernetes

kubernetes aspnet core

It is rightly said that Kubernetes (also known as K8s) is everywhere and if you are not using it then you are missing a big thing. Kubernetes is an open-source system developed by Google engineers and released on June 6, 2014. It took the world by storm since it can reduce the complexities of managing an app running on server.

Today every cloud service provider has Kubernetes service which developers can use to host their app. Azure has Azure Kubernetes Service (AKS), Google Cloud has Google Kubernetes Engine (GKE), while Amazon has Amazon Elastic Kubernetes Service (Amazon EKS). Even smaller cloud providers like DigitalOcean, Vultr & linode also provides k8s service to their customers.

What Kubernetes is and what it can do for you

Kubernetes is rightly said as a container orchestration platform that automates many of the manual process involved in deploying, managing and scaling of containerized applications. It removes a lot of complexities and runs your app smoothly for you.

Docker is a very popular container based platform that runs apps inside containers. You can run your ASP.NET Core app inside one or more docker containers. Then you can ask your system engineer to deploy these containers to Azure and manage them.

After deployment your system engineer will have to keep on eye on these containers so that they are up and running 24×7. If any container crashes then he will restart it, if containers experience heavy loads due to heavy traffic then he will scale up the containers to meet the requirements.

These are all orchestration task which the system engineer has to do.
Now here comes Kubernetes role. K8s will play the role of orchestrator and will manage these docker containers. So if any container crashes then it will automatically restart them, it will scale up and scale down the containers if the need arises. K8s will updates the app running on containers so that there is zero downtime. This reduces so much work of a system engineer. In the below diagram I have tried to explain the working of Kubernetes.

kubernetes container orchestration platform

Kubernetes Components

A Kubernetes cluster is a set of node machines for running containerized applications. If you’re running Kubernetes, you’re running a cluster. When you deploy Kubernetes, you get a cluster.

So, there can one or more clusters in a Kubernetes installation and every cluster has at least one worker node.

Kubernetes cluster is divided into 2 parts:

  • 1. Control Plane
  • 2. Worker Nodes (or simple “Nodes”)

Control Plane

The control plane is the brain of Kubernetes cluster. It makes decisions about what k8s has to do like scheduling, starting a new pod and many other tasks. The control plane has the following components:

kube-apiserver – it is through this component that other kubernetes components communicate with one another. Communication is done by the help of REST APIs.

etcd – it is a key-value store for all cluster data.
kube-scheduler -watches for newly created Pods and assigns Worker Nodes for them.

kube-controller-manager – it runs controller processes like Node Controller, Job Controller, Token Controller, etc.

cloud-controller-manager – it lets you link your cluster into your cloud provider’s API like linking to Azure, Google Cloud or AWS. Then you can manage the k8s cluster running in the cloud.

Worker Nodes

A worker node’s work is to hosts Pods. I will take the Pods in just a moment, in short you can understand pods as a program that holds one or more docker containers. Recall that your app runs in one or more docker containers. So, it means pods are actually managing these docker containers and hence your app. Worker Nodes are commonly called as Nodes.

kubernetes pods

The Worker Nodes has the following components:

kubelet – it is an agent that runs on each Worker Node. It’s work is to make sure that all containers are running in Pods.

kube-proxy – it is a network proxy that runs on each node. It maintains network rules on nodes. With these network rules, network communication to the Pods are governed.

Container Runtime – it is responsible for running containers.

Installing Kubernetes

Installing Kubernetes is simple as Docker Desktop does most of the heavy lifting for us. Open Docker Desktop and go to it’s settings. Then go to the Kubernetes section given on the left area. You will be presented with a screen as shown below.

kubernetes docker desktop

Here, check the option Enable Kubernetes, and click the button Apply & Restart. This will install Kubernetes on your system.

You will also need 2 tools to work with Kubernetes. These are:

  • 1. kubectl
  • 2. minikube


kubectl is a command line tool and has commands which you will run to manage your Kubernetes cluster. See it’s installation instruction for Linux, macOS and Windows operations system at here.

I am using Windows 10 Home so in my case I simply have to run the below command on my command prompt window and this will install kubectl on my system.

curl -LO

The curl command will download the Kubectl and install it on my system.

To verify Kubectl is installed correctly in your system, run the below command to you command prompt.

kubectl cluster-info

You will should see the messages saying Kubernetes master and KubeDNS are running successfully. See below image:

kubectl cluster info


minikube is a tool that runs a single-node Kubernetes cluster on your personal computer running on Windows, macOS or Linux PCs. The installation procedure is given at here.

For my case (Windows 10 Home) simply download minikube installer exe file and double click it to install it on your system. The download link to minikube is here.

Next, on your command prompt run the minikube start command which will start minikube on your system.

minikube start

You will receive a message which basically suggest that minikube is working properly and configured with kubectl. See the below image where I have shown this message.

minikube start

Then run the minikube status command which tells the necessary Kubernetes components are running.

minikube status

Check the below screenshot:

minikube status command

Well, that’s it. You are now ready to start using and learning Kubernetes. Check the below sections for our tutorials on k8s. I will be publishing all the necessary tutorials which you will need for using k8s with ASP.NET Core.