Remember those containers we created with docker one container easy to manage but imagine your application is running hundreds of them, some can crush, traffics increases and you need more containers and they're are running across different computers. So who manages all of these, that's where Kubernetes comes in.
Here is the thing, Docker is great at packaging and running containers BUT docker doesn't decide which computer these containers should run on. It doesn't automatically manage what happens when a container crushes, it doesn't even scale your application when traffic suddenly increases.
Docker builds the box but it doesn't manages 100 boxes spread across different containers. Something else has to do that and that's Kubernetes
So let's build this app, one problem at a time. First problem you have a container and it has to run on an actual computer somewhere, Kubernetes is design to spread your containers across multiple computers each of those computers are called a node.
A node could be a physical server running in a Data center or a virtual machine running in the cloud. Simply put A Node is a computer that Kubernetes can use to run your application. Put the container on a node problem solved right. Not quite Kubernetes needs to do things with your application restart it if crashes, replace it if it falls, move it to another node if the current node goes down. If Kubernetes only knew about a raw container it wouldn't have an easy way to manage all of that so Kubernetes can wrap your container in something it actually understands. That trapper is called a POD.
Technically, a pod is the smallest deployable units that Kubernetes manages simply put a pod is a pod is the unit that Kubernetes uses to run and manage your containers. Most of the time a pod contains one application container but a pod can also contain multiple containers especially when they need to work closely together.
A node is a computer and a pod runs on that computer. One node can run several pods at the same time so you might have one node running several pods and another one running even more so Kubernetes manages where these pods will run. But there's a problem, if one node goes down every pod running on it goes down your application cannot just depend on one computer. Kubernetes doesn't just manage one node, it manages multiple of them working closely together. That group of nodes is a cluster, simply put a Kubernetes cluster is a group of computers which we call nodes that are being managed by Kubernetes.
If one node fails Kubernetes creates a replacement pod and then run this replacement pod on other nodes. lets recap the cluster is the overall Kubernetes environment, inside the cluster are nodes which are the computer that provides the resources those nodes runs pods and those pods runs your application containers.
Now we understand the structure, let's see what Kubernetes actually does. Let's say you tell Kubernetes i want three pods running everything is fine. You have three pods and then one crashes without Kubernetes you might have to notice the problem and fix it yourself. But Kubernetes continuously monitors the state of your application. It knows you wanted three pods but now they are two, so Kubernetes creates a replacement until you have three pods again. This is one of the ideas behind self healing.
Now imagine traffic suddenly increases, three pods might not be enough. Kubernetes can also help with scaling instead of running three pods you can run 10, 50 or 100 depending on your application and the available resources and when demand decreases the number of pods can be reduced again, this is called Scaling and when systems automatically adjust the number of pods depending on demand that's called Auto-Scaling.
But here's another problem, If Kubernetes creates new pods where should they run remember the nodes from earlier; Kubernetes has a component called a Scheduler. So it's job is to decide which node should run a new pod it considers things like available CPU, available memory and rules that you've configured. So if a node is already bu9st Kubernetes places the new pod inside node 2, which eventually helps distributing workload across the cluster.
So the next time here this application runs on a Kubernetes, picture a cluster with multiple nodes and those nodes runs multiple pods and the pods run your application containers
In summary Docker helps you package and run your applications inside containers. Kubernetes on the other hand takes those containers manages them through pods places these pods inside nodes and organizes these nodes inside a cluster. It can restart pods when they fail, scale them when demand changes and schedule them across your available nodes. Kubernetes is all about managing your containers but at scale.
Top comments (0)