Kubernetes Simplified

Jed Lee
7 min readJul 27, 2023

A very surface level overview of Kubernetes

Photo by Growtika on Unsplash

Content of this Article

  1. Introduction
  2. Need for Kubernetes
  3. What is a Pod, Container, Containerisation or Containerised Applications?
  4. Key Components of Kubernetes & Contextualising Kubernetes
  5. Example Project that uses Kubernetes
  6. Conclusion

Introduction

Kubernetes, also known as K8s, is an open-source container orchestration system developed by Google, designed to help you manage applications that are made up of many containers (containerised applications) in different deployment environments.

Too complicated? Let’s dumb it down.

Think of Kubernetes as a maestro conducting an orchestra. It ensures all parts play in harmony, delivering a flawless performance regardless of the complexity of the piece (application).

For a teenager, imagine you’re playing a complex online multiplayer game. You need a system to manage all the players, game rules, and actions — that’s what Kubernetes does, but for software applications.

Need for Kubernetes

Photo by Yi Liu on Unsplash

The rise of microservices and container technology led to the need for Kubernetes. Microservices are small, independent applications that can be developed and scaled separately, while containers provide a lightweight and portable environment for hosting these microservices.

As applications evolved into complex architectures composed of hundreds or thousands of containers, managing all that was a complex task. It was like trying to juggle more and more balls — the more containers you had, the harder it was to keep them all in the air. Kubernetes came as a solution to this problem.

What is a Pod, Container, Containerisation or Containerised Application?

In Kubernetes, containers are the smallest units of computing. Instead of running containers individually, they are grouped together into “Pods.” Pods are the smallest deployable units in Kubernetes and serve as an abstraction over containers.

A Pod can contain one or more containers, typically just one.

The concept of Pods allows for convenient management of related containers that need to coexist and communicate within the same host, while containers themselves are responsible for running the application code.

Containerisation is a method of packaging an application along with its required environment, libraries, and dependencies into a single object, known as a container. This ensures that the application runs the same, regardless of the environment it is deployed in.

For example, let’s say you developed an application on your laptop, and it works perfectly. But when you try to run it on a server, it doesn’t work because the server is missing a library that your application needs. Containerisation solves this problem by including everything your application needs to run inside a container.

Containerised Application are applications that are made up of many containers.

Key Concepts of Kubernetes & Contextualising Kubernetes

I attended a Chinese Orchestra on 23rd July 2023

In a Chinese Orchestra, each musician plays a different instrument, such as the erhu 二胡, pipa 琵琶, or guzheng 古筝. Each instrument has its own unique sound and role in the orchestra, and it’s the conductor’s job to ensure they all play together in harmony to create beautiful music.

Similarly, in a computing environment, each container can be thought of as a different instrument. Each container runs a different piece of software, or “plays a different tune”, and it’s Kubernetes’ job to ensure they all work together.

Here are 8 key Concepts of Kubernetes in this context:

  1. Pods as Musicians: In Kubernetes, a Pod is the smallest and simplest unit that you can interact with. You can think of a Pod as a musician in the orchestra. Each musician (Pod) can play an instrument (container), and sometimes multiple instruments (multi-container Pods).
  2. Scheduler as the Conductor: The scheduler is responsible for distributing work or containers across multiple nodes by taking into account the availability of resources, quality of service requirements, policy constraints, and other specifications. As a conductor, he/she decides which musician plays which part of the composition, based on their skills (resources) and the requirements of the part (pod).
  3. Services as a Section Leader: Services route traffic to Pods. Let’s say you have a section of erhu musicians. The section leader (Service) knows all the musicians (Pods) and can direct any requests (like a solo part) to any musician. If a musician is unable to play (a Pod fails), the section leader can quickly redirect the solo to another musician. This ensures that the music (service) continues seamlessly, without the audience (users) knowing about the change.
  4. Deployment as Orchestra Rehearsals: Deployments manage the desired state of your application, similar to how rehearsals ensure that the orchestra performs as expected during the concert. A deployment controller provides declarative updates for Pods and ReplicaSets. A deployment in Kubernetes ensures that the desired number of Pods are running and changes the actual state to the desired state at a controlled rate.
  5. Load Balancing as Volume Control: Just as a conductor balances the volume of different sections for a harmonious performance, Load Balancing in Kubernetes ensures that the network traffic is distributed evenly across the Pods for efficient performance and preventing any one component from becoming a bottleneck.
  6. Fault Tolerance as Handling Mistakes: In an orchestra, if a musician makes a mistake or was not able to play, the conductor will help the ensemble recover. Similarly, Kubernetes has a fault tolerance mechanism. With its self-healing capabilities, Kubernetes detects container failures and automatically restarts or replaces them to maintain the desired state and application availability.
  7. Ingress as Ticketing and Entrance System: Ingress in Kubernetes is an API object that manages external access to the services in a cluster, typically HTTP. Ingress can provide load balancing, SSL termination, and name-based virtual hosting. In an Orchestra, ingress manages the access of the audience (external traffic) to the performance (services). It can handle different entrances (paths) to different sections of the concert hall (services).
  8. StatefulSets as Music Sheets: StatefulSets is a Kubernetes workload API object that manages stateful applications. StatefulSets are like music sheets for each musician. It ensure that each Pod (musician) has its own unique identity and state (music sheet), which is important for certain applications (instruments) to function correctly like the guzheng or pipa, where tuning and string placement must be preserved (stateful) for the music to sound correct.

Just as a conductor ensures that the orchestra performs in harmony, Kubernetes ensures that all of the containers in an application work together seamlessly.

Example Project that uses Kubernetes

Let’s say you’re working on a project to predict the weather. You have a large dataset and a complex machine-learning model. You need to preprocess the data, train your model, evaluate it, and then deploy it so that it can be accessed by others.

Photo by Randy Fath on Unsplash

This is where Kubernetes comes in. It can manage the deployment of your data preprocessing jobs, model training and evaluation, ensuring it’s always available and can handle multiple requests at once. If your model becomes popular and you start getting more traffic, Kubernetes can automatically scale up your resources to handle the increased load.

Let’s break down the steps a Data Scientist will take:

  1. Data Collection: You might have multiple sources for your weather data, such as different APIs for temperature, humidity, wind speed, etc. Each of these could be a separate job running on Kubernetes, pulling data at regular intervals.
  2. Data Cleaning: The raw data might have missing values, outliers, or other inconsistencies. You could have a series of Kubernetes jobs that clean and preprocess this data.
  3. Data Storage: The cleaned data needs to be stored somewhere. You might use a database that’s hosted on Kubernetes, or a cloud storage service like AWS S3 can be integrated.
  4. Model Training: Training a machine learning model on a large dataset can be resource-intensive. Kubernetes can manage the resources needed for this process, scheduling the training job to run when resources are available.
  5. Model Serving: Once the model is trained, it needs to be deployed so that it can be used to make predictions. Kubernetes can manage this deployment, ensuring that the model is always available and can scale to handle multiple requests.
  6. Monitoring: You need to keep track of the model’s performance and the overall system's health. Kubernetes can host monitoring and logging tools like Prometheus and Grafana, which can alert you to any issues.

Without Kubernetes, these steps would require manual management, which can be time-consuming and error-prone. Kubernetes automates much of this process, ensuring that jobs run smoothly and resources are used efficiently.

Conclusion

I hope that this general overview of Kubernetes has helped you understand Kubernetes ever slightly better. It sure did help a lot for me.

There are still a couple more components, details, and functions of Kubernetes that I am not able to contain in my article. The only way to fully understand and use Kubernetes is to get hands-on with it.

Thanks so much for reading my article!!! Feel free to drop me any comments, suggestions, and follow me on LinkedIn!

--

--

Jed Lee

Passionate about AI & NLP. Based in Singapore. Currently a Data Scientist at PatSnap.