Kubernetes Fundamentals
Introduction to Kubernetes
What is Kubernetes?
Kubernetes is a system for managing applications that run in containers. Think of it as an orchestrator for a symphony of software components. It automates the deployment, scaling, and operation of applications, ensuring they run smoothly and reliably, no matter the demand.
Developed by Google and now maintained by the Cloud Native Computing Foundation, its name comes from the Greek word for "helmsman" or "pilot." That's a fitting description for a tool that steers your applications through the complexities of a live production environment. You'll often see it abbreviated as K8s, where the "8" represents the eight letters between 'K' and 's'.
Kubernetes (K8s) is the open source platform of modern container orchestration.
The Road to Containers
To understand why Kubernetes is so important, let's look at how we used to deploy software.
In the past, applications were often installed directly onto a physical server. This was simple, but inefficient. You couldn't easily control how much of the server's resources an application used, leading to wasted capacity. If you ran multiple applications on one server, they could interfere with each other.
Next came virtual machines (VMs). A single physical server could host multiple VMs, each with its own operating system and a slice of the server's resources. This improved isolation and resource use, but each VM carried the overhead of a full OS, making them bulky and slow to start.
Containers are the next step in this evolution. A container packages an application and its dependencies into a single, isolated unit. Unlike VMs, containers share the host server's operating system kernel, making them incredibly lightweight and fast. You can run many more containers on a server than you could VMs. But this new approach brought its own set of challenges. How do you manage hundreds or thousands of containers running across many different servers?
This is where an orchestrator comes in.
Kubernetes Architecture
A Kubernetes setup is called a cluster. A cluster is made up of multiple computers, or nodes, that work together. This distributed nature is what makes it so resilient.
At a high level, a cluster has two main parts.
The Control Plane: This is the brain of the operation. It makes all the decisions about the cluster, like scheduling applications, responding to failures, and scaling. It's responsible for maintaining the desired state of the cluster.
Worker Nodes: These are the machines (virtual or physical) that do the actual work. They run the applications in containers as instructed by the control plane. Each worker node reports its health back to the control plane.
Kubernetes follows a master–worker (control plane–node) model:
You tell the control plane what you want your application setup to look like—for example, "I want three copies of my web server running." The control plane then works with the worker nodes to make it happen. If a worker node fails, the control plane will reschedule the applications that were running on it to other, healthy nodes.
Key Features and Concepts
Kubernetes provides a framework for running distributed systems resiliently. It manages the lifecycle of your applications and offers several key features automatically.
-
Self-Healing: If a container crashes, Kubernetes automatically restarts it. If a whole node dies, it replaces and reschedules the containers that were on it. It also kills containers that don't respond to health checks.
-
Horizontal Scaling: Need more capacity? You can scale up your application with a single command, or you can configure Kubernetes to do it automatically based on CPU usage or other metrics.
-
Service Discovery and Load Balancing: Kubernetes gives containers their own IP addresses and a single DNS name for a set of containers. It can then load-balance traffic across them, so you don't have to worry about how containers find each other.
To work with Kubernetes, you'll need to know a few basic building blocks.
Pod
noun
The smallest and simplest unit in the Kubernetes object model that you create or deploy. A Pod represents a single instance of a running process in your cluster and can contain one or more containers.
Containers within the same Pod share a network and storage, so they can easily communicate with each other as if they were on the same machine.
Service: Pods are mortal; they are created and destroyed. A Service provides a stable endpoint (a fixed IP address and DNS name) for a set of Pods. This allows other applications to reliably connect to them without needing to know the specific IP addresses of the individual Pods, which can change.
Deployment: A Deployment is where you describe the desired state for your application. You might specify, "I want three Pods running the v1.2 image of my app." The Deployment Controller then works to make that state a reality. If you want to update your application, you update the Deployment, and Kubernetes will handle rolling out the change with zero downtime.
These concepts are the foundation for building and managing robust applications in Kubernetes. By defining your application using these objects, you let Kubernetes handle the difficult work of keeping everything running as it should.
What is the primary function of Kubernetes?
The name 'Kubernetes' is a Greek word. What is its English translation?