Hi Friends,
Welcome to the 62nd issue of the Polymathic Engineer newsletter. This week's topics are container orchestration and Kubernetes.
The outline will be as follows:
Containers orchestration
What is Kubernetes
A brief history
Kubernetes architecture
Control Plane
Workers Nodes
Pods
Replica Sets and Deployments
Declarative configuration
Advantages and disadvantages
Containers orchestration
Over the last few years, we have observed two main trends in software development. The first one was the migration from Monolith architectures to Microservices.
Rather than having an entire application run as a single unit, software engineers broke down the individual components (e.g., database, authentication, payment, logging, etc.) into different services. Each service is exposed with a set of APIs to the other services or to external clients.
The second trend was the use of containers to deploy applications. This is relatively straightforward with a simple application and Docker. You create a Docker file, build the container, put it somewhere, and run it. However, manually managing containers in large microservices applications can soon become a nightmare.
Every service typically runs in its own container, and several copies of each service may also be necessary for horizontal scalability.
Such a scenario has many challenges. How do those containers communicate with each other? How do they discover each other? How can you distribute traffic between those containers at scale? How can you log and monitor your application? How can you debug containers if the application is too large to run on a single machine?
Here is where an orchestration platform comes into play. An orchestration platform is software that can manage many containers across multiple hosts.
Some of the features that an orchestration platform provides are:
Scheduling: start, stop, and manage container instances
Affinity/anti-affinity: force group of containers to work together on the same machine or different machines
Health monitoring: detect and fix container failures
Failover: provision new instances of a container to a healthy machine
Scaling: add/remove container instances to meet different demand
Networking: provide an overlay networking layer for container communication
Service discovery: Enable containers to locate each other
Upgrades: coordinate application upgrades to avoid downtime and execute rollback procedures in case of issues
What is Kubernetes
Kubernetes is an open-source orchestration platform that can easily manage clusters with thousands of containers.
Its adoption is so widespread that it has become the de facto standard to automate containerized applications' deployment, scaling, and management.
Kubernetes abstracts any infrastructure details from the developers. They don't have to think about manually provisioning containers or restarting failed ones. They describe the desired application architecture, and Kubernetes makes it happen and keeps it running.
Typically, the developers create manifest files for their applications and give them to Kubernetes. Kubernetes checks the files and deploys the necessary containers to its cluster of machines. Afterward, Kubernetes manages the complete lifecycle of the applications according to the manifest files.