Kubernetes 101: A Beginner's Guide

Kubernetes is a very important tool. Cloud Native Computing Foundation estimates that Kubernetes has a 96% market share in the container orchestration space. According to a Flexera study, 78% of small and medium sized businesses use Kubernetes. This is why learning kubernetes is imperative today. Here is a guide to the basics of Kubernetes.

What is Kubernetes?

Kubernetes is a container orchestration service. But that doesn't mean much, does it? Here is a more practical example.

Imagine you are a server admin. you have 1 server to manage with 1 docker container. Your job is to make sure they are up. Sounds easy enough, right? Now, imagine you have 100 different containers to manage. You have to make sure they scale properly, mitigate and properly respond to failure, manage security, make updates, and do all that across all the containers. Now, let's say you had to do that across 100 servers. Sounds like a nightmare, right? Now consider that several companies run at a way bigger scale. Now, you start to see the problem that Kubernetes tries to solve.

Kubernetes Core Concepts

Kubernetes is a very complicated tool. It has many moving parts to it. Here are the very basics that you need to know before using a Kubernetes cluster.

  • Pods: A pod is the smallest deployable unit in kubernetes. In most cases, a pod is 1 container, but a pod can also have several containers. All the containers in a pod are tightly coupled. This means they share the same networking, storage, and other resources.
  • Nodes: Nodes are often referred to as workers in kubernetes. They are the machines that run the pods. They have several services to help them do so.
  • ReplicaSets: ReplicaSets ensure that a certain number of pods are always running in the kubernetes cluster
  • Services: Services are what enable network communication. They are an abstraction on top of pod IP addresses.
  • Deployments: This is a way to manage the creation of replicasets.

Kubernetes Architecture

A Kubernetes cluster has 2 pieces to it. The first is the control plane and second is the worker. The control plane is also often called the master. It tells the workers what to do. The workers do the job. Both the parts of the cluster have multiple components to them. Let's explore that.

  • Control Plane
    • API Server: This is the process that runs the Kubernetes API. When you make an API call, it communicates with either the other control plane processes or kubelet on the worker nodes to either finish the job or get the information.
    • Scheduler: The scheduler has a very specific job. It has to take pods that have been deployed and assign them a node. It interacts with the API server to do so
    • Controller manager: This is the component of Kubernetes that takes actions to take the cluster from the current state to the desired state. It interacts with the API Server to do so.
  • Worker Node
    • Kube Proxy: Kube Proxy is a network proxy that helps implement the service concept by forwarding packets.
    • Kubelet: Kubelet is the process that receives orders from the master nodes and executes on them.
    • Containerization engine: The containerization engine is the thing in the worker node that does all the work. It manages how containers are created and destroyed. You have several options here, but by far, the most popular one is docker.

Optional components

Along with all the components mentioned above, there are several optional components that you can add to your kubernetes cluster to get more functionality out of it.

Cloud Controller Manager (CCM)

The cloud controller manager is the kubernetes component that talks to the cloud provider's API. This is essential for cloud based deployments. Here is an example of where it might be used.

Let's say you have installed a kubernetes cluster in the cloud. Now, you create a load balancing service across several pods. Without a cloud controller manager, any requests coming into the service would automatically be load balanced by the nodes themselves. This is usually not much of a problem.

When you have the cloud controller manager configured, though, it will create a load balancer in the cloud provider. Yes, you will be charged for this separately, but the advantage is that your nodes do not have to deal with the traffic. Your cloud provider is doing that for you. It works similarly if you are using IP address services, you want to create persistent storage volume, or several other scenarios.

Ingress Controller

This is probably the best part of the whole cluster. Ingress controllers are used to route HTTP and HTTPS traffic throughout different kubernetes services. Here are just a few things an ingress controller can do.

  • Path Based Routing: Ingress controllers can route HTTP or HTTPS traffic based on what path they are going to. For example, you can direct traffic going to /shop to a different service than the traffic going to /home. This allows us to create microservice architectures with each path having it's own service.
  • Host Based Routing: Ingress controllers allow traffic to be routed to different services based on the hostname. For example, traffic headed to krishivpiduri.com can be routed to a different service than traffic headed to otherwebsite.com. This is great because you can now have several websites be hosted on a single IP in a single port.
  • SSL termination: It is not always easy to implement SSL on our websites. Ingress controllers allow SSL termination. This means, the connection from the client to the ingress controller is encrypted using SSL, while the connection from the controller to the service is unencrypted.

Of course, the features you have depends on the ingress controller you chose, but these are the basic features that most ingress controllers will have.

CoreDNS

CoreDNS is a pretty useful service. It is a DNS server for your cluster. This means, you can access services using their names. There really isn't much more to CoreDNS than that.

Service Mesh

Service Meshes are quite a unique service. Their goal is very simple, but they themselves are very complicated. Kind of like Kubernetes. Their main goal is to manage and monitor how different services communicate and interact. While that sounds very simple, it is surprisingly complex.

Conclusion

This post about kubernetes wasn't as long as long as I would have liked it to be. I wanted to keep it high level without going into the details. Unfortunately, kubernetes is not that complicated. I also have a guide on how to install kubernetes in your own environment so you can experiment and learn with it. The link is here. Until then, I wanted to leave you with a gift. Here is a little reference guide to some of the important things I said here.

Comments

Popular posts from this blog

Persistent Data in Docker: Explanation + Hands-On Demo

Pods to Deployments | Kubernetes Architecture Evolution

Docker Compose Explained: Simplifying Multi-Container Deployments