Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Kubernetes (k8s)

Kubernetes, or k8s for short, is a container orchestration system.

It enables declaratively configuring how many instances (replicas) of a service you want running, rather than having to manually set up the desired number of instances on each VM and monitor them.

In a deployment, one or more containers can run on one VM, and one or more VMs can run on one server, of which there can be many. In a Kubernetes deployment, the VMs are called pods, the servers are called worker nodes, and the group of nodes is called a cluster. The are orchestrated by a control plane (controllers), mot of which runs on a separate, non-worker node within the cluster.

The computational tasks performed by a system are called its load. A cloud deployment may have thousands of requests per second, each representing a computational task. A single container or pod can handle only so many requests, or traffic, before one of its resources (network I/O, CPU, memory) either becomes a bottleneck (slowing the system’s response time) or crashes the container or pod. To avoid this, requests are sent to a load balancer which then delegates to a container or pod that has available resources. The load balancer tries to evenly distribute the load, for example, using 80% of resources on five machines rather than 100% of resources on only four of them.

When the system load increases or decreases, Kubernetes will scale by creating or removing extra pods as necessary. This means that pods are ephemeral (short-lived). Because pods are just VMs, every time one is created, it will have a new IP address. The load balancer keeps track of which pod IP addresses to send requests to, and provides a stable API endpoint for each service for requests to be sent to.

When a new version of the software is deployed, the container image is updated. Kubernetes handles rolling updates, in containers are gradually redeployed from the new image, ensuring zero downtime. With rolling updates, the container image can be rolled back if the new version is failing.

Scaling

Horizontal Pod Autoscaling (HPA) means more pods. Configuration includes:

Vertical Pod Autoscaling (VPA) means pods that have more resources. This is required for:

Cluster Autoscaling means more nodes, and is invoked when existing nodes are at their limits. Configuration includes:

The Control Plane

The control plane consists of a number of components:

References