Kubernetes from the beginning: Part 1

Kalana Wijethunga
Nov 3 · 5 min read
https://stackify.com/kubernetes-docker-deployments/

Kuberenetes has become a buzz word these days. Everybody is looking to into learning Kubernetes, but without a correct idea on what Kubernetes is. Therefore this blog will introduce you to Kubernetes and its basics.

Kubernetes is an open-source container-orchestration system for automating application deployment, scaling, and management.

What is Kubernetes?

In order to talk about Kubernetes a.k.a k8s, we must talk about container runtimes. Everyone knows what Docker is right? In case you don’t, Docker is the most widely used container runtime in the world today. When you want to containerize your application to make sure it works in any environment without having to install separate libraries, required dependecies etc. , you go to Docker (or any other container runtime like containerd or rkt). You write a Dockerfile to convert your application into a Docker image and this Docker image can deploy your application as a container in any environment which has the Docker engine installed. Now your application is available as a container for anyone to use, but can you just use this container in production? What if the container gets killed?

This is where k8s come into play. If you refer Docker containers as workers in a factoy (who does the work like serving HTTP requests, doing calculations etc. ) you can understand k8s as the factory manager. It manages the containers by assigning the correct workload, checking the health of the containers, checking whether a container is alive or killed etc. The most important task of k8s is that it makes sure a given number of containers of the application is running at any given time, so at production you don’t have to worry about things like what if the container gets killed? If you container gets killed, k8s make sure another container is spawned and serves the work of the killed container. In other words, k8s make sure your application containers are production ready with a production grade management of containers.This management of containers is called “container-orchestration”.

Basic Components of Kubernetes

Kubernetes essentially requires a Kubernetes cluster. This cluster contains of a Kubernetes master and a set of nodes. A node is a virtual/physical machine which is used to deploy your application. When you reserve few PCs as nodes, k8s is capable of creating one or more clusters by combining the resources of few PCs together.

Kubernetes Architecture (https://platform9.com/blog/kubernetes-enterprise-chapter-2-kubernetes-architecture-concepts/)

kubectl is a CLI tool which can be used to send commands to the k8s master.

Kubernetes node components

Each node has a kubelet and a container runtime installed.

  • Container runtime is required to run applications as containers in the nodes.
  • Kubelet acts as Kubernetes agent on the node (just like puppet agent in Puppet) which maintains the communication between k8s master and the node.

Although we refer k8s master as a single components it is actually a combination of several components, mainly kube api server, scheduler, etcd and controller manager.

Kubernetes Master Components.

  • kube api server is used to expose the k8s functionalities to the outside. You can send requests like create a deployment to the kube api server and it will make sure a new deployment is created in the cluster by passing the request to the k8s master.
  • etcd is a high available key-value store which is used to store cluster data.
  • scheduler watches the newly created pods which have no node assigned and assign them a node to get depolyed on.

I have explained only the most important components of k8s here, you can read more about them from k8s official documentation here.

Kubernetes Workflow

You use kubectl CLI tool to send commands to the k8s master. kubectl sends this commands as API calls to kube api server which transfers these requests to the k8s master. scheduler checks the newly created resources and assigns a node to them. kube api server communicates this information to the relevant kubelet and kubelet makes sure that the container runtime deploys the required resources on that node.

Advantage of using Kubernetes for Container Management

  • Make sure a given number of containers are up and working at any given time → In case one container gets killed, k8s spawn an identical container.
  • Check for defective containers and replace them with new containers → Does periodical health checks and kill the containers which fail the health checks.
  • Scale up or down the number of containers easily. → You can easily define the number of containers required in your k8s cluster and it will scale up or down without breaking any functionality.
  • Reusable on any infrastructure → The k8s artifacts you create are reusable across any infrastructure with a k8s cluster and you don’t have to change a single line of code when you change your infrastructure.
  • Zero Downtime → If you are changing or upgrading your cluster, k8s can deploy the changes gradually without having any downtime by performing rolling updates.
  • FOSS → The best thing about k8s is that it is Free and Open Source. So you can have all these great features at no cost.

If you are just getting into learning Kubernetes, it would be overwhelming to familiarize yourself with learning all these new concepts. So I think it would be enough for today. See you all with the next article on Kubernetes.

References

  1. https://www.quora.com/What-is-orchestration
  2. https://www.linode.com/docs/applications/containers/kubernetes/kubernetes-use-cases/
  3. https://kubernetes.io/docs/concepts/overview/components/

Follow us on Twitter 🐦 and Facebook 👥 and join our Facebook Group 💬.

To join our community Slack 🗣️ and read our weekly Faun topics 🗞️, click here⬇

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author! ⬇

Faun

The Must-Read Publication for Aspiring Developers & DevOps Enthusiasts. Medium’s largest DevOps publication.

Kalana Wijethunga

Written by

Software Engineering Intern @WSO2| Undergrad | Technophile |Team Player

Faun

Faun

The Must-Read Publication for Aspiring Developers & DevOps Enthusiasts. Medium’s largest DevOps publication.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade