Legacy Kubernetes - Arthyon/microservice-poc GitHub Wiki

We are using Kubernetes as the container orchestrator. Deployments to Kubernetes is done using a .yml-file which describes the desired environment. When we are deploying from Azure DevOps, we deploy all services, and Kubernetes will figure out which ones that changed, e.g. a new image or more replicas.

Basic Terminology

Our Kubernetes setup uses pods, deployments and services.

Pods

Pods are where our container is hosted. The number of replicas defined in the yml-file corresponds to the instances of pods currently running.

Services

Since there can be a variable number of pods for each container, we need some way to a) connect to other pods in our cluster from a second pod, and b) expose some of our pods outside of the cluster. We use services to accomplish both of these tasks. When we define a service, we create an internal hostname with which a service can connect to a collection of pods. Think of it as a load balancer for all instances of a specific service. This uses the default service type ClusterIP.

To expose a service out of our container, we use the service LoadBalancer. This exposes a pod cluster out of Kubernetes on a specific external ip. Our gateway is exposed in this manner to enable external access.

Deployments

A deployment is used to describe the desired state of the system. Our .yml-file is using deployments to instantiate pods and services.

Setting up Kubernetes with Azure Devops

This guide is an excellent starting point that describes the whole process. The gist is that we define an .yml-file that references all our container images. We create a release pipeline that uses artifacts from each service as input, and replaces tokens in the .yml-file with environment variables from the input artifacts.

Note: The replace tokens-task we are using is a task from the marketplace, so the person setting up Azure DevOps must be allowed to install plugins.

The end result is a single yml-file that describes the whole infrastructure and where to find the container images. The release pipeline will also take care of updating Kubernetes' connection to our private docker repository.

Api Management

If more flexibility is required than Ocelot can deliver, it is possible to use Azure Api Management in production. This guide describes how to set up Api Management.

The downside to using Azure Api Management is that we need to maintain two different setups for routing to our Microservice. Switch with care.