3 Deploying a microservice to Kubernetes

 

This chapter covers

  • Packaging a microservice in a Docker container
  • Deploying a microservice container to Kubernetes on localhost
  • Creating a basic Kubernetes cluster on Azure’s AKS (Azure Kubernetes Service)
  • Deploying a microservice container to a Kubernetes cluster on AKS

In chapter 2, we developed a simple shopping cart microservice, but we only ran it on localhost directly with the dotnet run command. In this chapter, we take that microservice and deploy it to a production-like environment in a public cloud. Our microservices can run in many different environments, but we are going to pick just one as an example. We are going to focus on how to take the shopping cart microservice and run it in a Kubernetes cluster in Microsoft Azure. To reach that goal, in this chapter we will:

  • Put the shopping cart into a Docker container
  • Set up Kubernetes on localhost, so we have a testing ground
  • Set up Kubernetes in Azure, so we have a production-like environment
  • Run the same shopping cart container in the localhost Kubernetes cluster and the Azure Kubernetes cluster

3.1 Choosing a production environment

3.2 Putting the Shopping Cart microservice in a container

3.2.1 Adding a Dockerfile to the Shopping Cart microservice

3.2.2 Building and running the shopping cart container

3.3 Running the shopping cart container in Kubernetes

3.3.1 Setting up Kubernetes localhost

3.4 Creating Kubernetes deployment for the shopping cart

3.5 Running the shopping cart container on Azure Kubernetes Service

3.5.1 Setting up AKS

3.5.2 Running the shopping cart in AKS

Summary