Of Buildings and Helms: A Quick Guide to Understanding Kubernetes
This is the first of (hopefully) many posts that aim to explain how Kubernetes works in an easy to understand way. This will assume you have basic knowledge of containers - if you don’t, please take some time to read about them as it’s absolutely necessary in order to fully understand Kubernetes.
We’ll also be using terraform to create and manage our infrastucture on Google Cloud Platform, so you need to install terraform and set up a GCP project and credentials.
Example - GCP provider setup
NOTE: If you already have terraform, please note that the examples provided here will work only on terraform 0.12 or newer. Syntax adjustments may be necessary if you’re using an older version.
What is Kubernetes?
You can think of Kubernetes as a “condo for applications”. It provides infrastructure services that allow the applications to run and access powerful and handy features such as storage or load balancing.
In order to have a functioning Kubernetes environment we’ll need to set up some foundations for it to lay on. The first thing we’ll need is the network where the servers hosting the infrastucture will be.
Example - GCP network and subnetwork
Kubernetes installations are tipically clusters, with multiple servers working together in order to control and provide resources to the applications residing within them. I’ll talk about server roles and services in another post, but for now just think that the cluster is the condo itself.
There are many ways to create a Kubernetes cluster, but for the sake of simplicity we’ll stick to some managed services for now. I’ll include terraform recipes to launch the cluster on Google Cloud Platform (GCP).
Example - GCP K8s cluster
Applications in a cluster need servers to host them and provide them the resources - CPU, memory, storage - they need in order to run. These servers are generally organized in pools according to their characteristics, so you can have multiple server “profiles” in different pools in order to meet different application requirements. Using our condo example, the pools would be groups of similar buildings inside that bigger condo.
We’ll create a single pool consisting of one server in here so that our environment won’t be expensive, but feel free to resize the pool or add more as you see fit: all you need to do is add extra pools in your terraform configuration file.
Example - GCP K8s pool
Connecting to your Cluster
Pods are the smallest deployable unit in kubernetes - think of a room in an apartment or office. A pod is very often a single container, although it may also be a group of containers that share resources such as storage and network. Different pods will have separate resources - if a process in a pod needs to communicate with a process in another pod it will have to do so across the network, and each pod will have its own IP address.