Core Concepts K8s

TECH

9/22/20231 min read

  1. ETCD
    • Part of control plane

    • key-value database

    • Stores all the k8s resources, objects

    • etcdctl get / --prefix -keys-only

  2. Kube API Server
    • Part of control plane

    • The only component that directly talks to ETCD

    • Whenever we run any get command with kubectl, it goes to the API server for

      • Authenticate user

      • Validate user

      • Retrieve data from ETCD

      • Update ETCD

      • Scheduler

      • Kubelet

  3. Kube Controller manager
    1. Part of control plane

    2. Node controller: Monitor the status of nodes. If not reachable, mark them not reachable.

    3. Replication controller: Make sure the desired number of replicas of a pod is always running

    4. Cloud controller: to provision cloud volumes

  4. Scheduler
    • Part of control plane

    • Actively monitor the API server for a new pod and find the right node for the pod using the scheduling framework.

    • Which pod goes where

    • Scheduling Framework

      • Pods are put in a queue

      • Pods are sorted based on priority in the queue

      • Nodes are filtered based on pod affinity or tolerations

      • Nodes are scored based on which one could be the best candidate. For example, the node which has more resources available can get a better score.

      • Pods go through a pre-bound step if there is any volume to be mounted etc.

      • Pods are bound to the best-scored node

    • If there is a new pod created and not assigned a node yet it identifies the right node to schedule the pod on and communicate back to the API server. API server then, in turn, updates the ETCD cluster. The Kube API server then passes the information to Kubelet in the chosen node. Kubelet creates a new pod by instructing container run time to deploy the images. Once done, it communicates back to the Kube API Server. The Kube API server updates the data in ETCD.

  5. Kubelet
    • Part of the worker plane

    • Monitor the nodes, and pods and report back to Kube API server about the status

  6. Kube Proxy
    1. Runs on each node

    2. Create IP table rules to forward requests coming to service IP to pod IPs

    3. Within a cluster, Every pod can reach any other pod using this Pod network solution called kube proxy