Science and technology

A visible map of a Kubernetes deployment

When you’re employed with containers on Kubernetes, you typically group functions collectively in a pod. When you launch a container or a pod into manufacturing, it is known as a deployment. If you are utilizing Kubernetes day by day and even simply weekly, you have in all probability finished it a whole bunch of occasions, however have you considered what precisely occurs if you create a pod or a deployment?

I discover it useful to have an understanding of the chain of occasions on a excessive degree. You haven’t got to know it, after all. It nonetheless works even when you do not know why. I do not intend to checklist each little factor that occurs, however I goal to cowl all the vital ones.

Here’s a visible map of how the totally different parts of Kubernetes work together:

You could discover within the diagram above that I have not included etcd. The API server is the one part that may instantly speak to etcd, and solely it may well make modifications to it. So you’ll be able to assume that etcd exists (hidden) behind the API server on this diagram. 

Also, I’m speaking about solely two essential controllers (Deployment and ReplicaSet) right here. Others would additionally work equally.

The steps under describe what occurs if you execute the kubectl create command:

Step 1: When you utilize the kubectl create command, an HTTP POST request will get despatched to the API server, which accommodates the deployment manifest. The API server shops this within the etcd information retailer and returns a response to the kubectl.

Steps 2 and three: The API server has a watch mechanism and all of the purchasers watching this get notified. A shopper watches for modifications by opening an HTTP connection to the API server, which streams notifications. One of these purchasers is the Deployment controller. The Deployment controller detects a Deployment object, and it creates a ReplicaSet with the present specification of the Deployment. This useful resource will get despatched again to the API server, which shops it within the etcd datastore.

Steps 4 and 5: Similar to the earlier step, all watchers get notified in regards to the change made within the API server—this time the ReplicaSet Controller picks up the change. The controller understands the specified duplicate counts and the pod selectors outlined within the object specification, creates the pod sources, and sends this data again to the API server, storing it within the etcd datastore.

Steps 6 and seven: Kubernetes now has all the data it must run the pod, however which node ought to the pods run on? The scheduler watches for pods that do not have a node assigned to them but, and begins its technique of filtering and rating all nodes to decide on the perfect node to run the pod on. Once the node is chosen, that data will get added to the pod specification. And it will get despatched again to the API server and saved within the etcd datastore.

Steps 8, 9, and 10: All the steps till now happen within the management aircraft itself. The employee node has but to do any work. The pod’s creation is not dealt with by the management aircraft, although. Instead, the kubelet service operating on all of the nodes watches for the pod specification within the API server to find out whether or not it must create any pods. The kubelet service operating on the node chosen by the scheduler will get the pod specification and instructs the container runtime within the employee node to create the container. This is when a container picture will get downloaded (if it isn’t already current) and the container really begins operating.

Understanding Kubernetes deployments

Gaining an understanding of this normal stream will help you perceive many occasions in Kubernetes. Consider a DemonSet or StatefulSet in Kubernetes. Apart from utilizing totally different controllers, the pod creation course of stays the identical.

Ask your self this: If the deployment will get modified to have three replicas of an app, what would the chain of occasions that result in the creation of the pods appear to be? You can check with the diagram or the listed steps, however you undoubtedly have the data it is advisable determine it out. Knowledge is energy, and also you now have an vital part for understanding Kubernetes.

Most Popular

To Top