What happens when you create a Pod in Kubernetes

Once you run kubectl run busybox --image busybox on your KubernetesKubernetes
Kubernetes is a container orchestration platform. This note serves as a Map of Content for this topic. Start your exploration on one of these notes:

K8S NodeK8S Node
In [[Kubernetes]], a Node is a (physical or virtual) machine in charge of running some workloads. Kubernetes is run entirely on nodes, and everything that happens on Kubernetes cluster, happens on ...

[[K8S Object]]
[[What happen...
cluster, what has to happen before your K8S PodK8S Pod
Pod is a [[K8S Object]] used to run one or more tightly coupled containers and is rarely used directly, especially in production because of the limitations on the number of properties that can be u...
is running successfully?

The K8S ApiserverK8S Apiserver
Kube Apiserver is the primary component of a [[Kubernetes]] cluster. It runs on a [[K8S Master Node]], and is the only component which is talking directly to the etcd clusteretcd cluster
Etcd is a reliable key-value [[Database]]. It is one of the most important parts of a [[Kubernetes]] cluster used to store the data of the [[K8S Apiserver]]. It uses [[Raft Protocol]] to establish ...
. It exposes a REST...
is the component which recieves your request, authenticates you, validates the request and writes your action into etcd clusteretcd cluster
Etcd is a reliable key-value [[Database]]. It is one of the most important parts of a [[Kubernetes]] cluster used to store the data of the [[K8S Apiserver]]. It uses [[Raft Protocol]] to establish ...
. At this point, the pod resource is created, but is in Pending state.

K8S SchedulerK8S Scheduler
[[Kubernetes]] scheduler is a [[K8S Master Node]] component in charge of K8S SchedulingK8S Scheduling
[[K8S Scheduler]] is making sure that every [[K8S Pod]] is assigned to a [[K8S Node]]. Every pod that gets created has a property NodeName which is not set by default. kube-scheduler looks for pods...
.



Status: #🌱

References:
is continuously monitoring the Apiserver for pods that require scheduling. Once it notices our pod is not assigned to a K8S NodeK8S Node
In [[Kubernetes]], a Node is a (physical or virtual) machine in charge of running some workloads. Kubernetes is run entirely on nodes, and everything that happens on Kubernetes cluster, happens on ...
, it will identify the node where the pod will be placed, and will inform Apiserver about this decision. This process is described in more detail in K8S SchedulingK8S Scheduling
[[K8S Scheduler]] is making sure that every [[K8S Pod]] is assigned to a [[K8S Node]]. Every pod that gets created has a property NodeName which is not set by default. kube-scheduler looks for pods...
.

Once Apiserver recieves the request from scheduler, it updates the etcd cluster and passes this information over to the KubeletKubelet
Kubelet runs on a [[Kubernetes]] node and is responsible for managing the node it's runnning on. It starts and stops nodes as requested by the [[K8S Apiserver]]. It also updates the kube apiserver ...
of the appropriate worker node.

The kubelet will then:

  • create the pod on the node
  • instruct the container runtime engine (K8S CRI) to deploy the application image
  • invoke the K8S CNIK8S CNI
    [[Kubernetes]] implements CNI(Container Network Interface) to allow third-party networking solutions to integrate with it.

    Each CNI solution needs to implement a set of things including, but not l...
    plugin to add the new pod to the pod network
  • configure DNS resolution in that pod so it can reach the services and pods by their domain names (DNS Resolution in KubernetesDNS Resolution in Kubernetes
    To figure out how [[DNS Resolution]] works in [[Kubernetes]], there are a few important components to consider:

    k8s DNS server running on the cluster (e.g. [[CoreDNS]])
    [[K8S Node]]'s local DN...
    )
  • update the status back to the Apiserver, who lastly updates the data again into the etcd cluster

At this point, your Pod is successfully running on a Node.


Status: #🌲