Skip to content

EN_K8s_Basics

somaz edited this page Mar 30, 2026 · 1 revision

Kubernetes Basics

Certainly! Here's the provided information about Kubernetes and container orchestration, translated into English and formatted in a code block:

markdown Copy code

Why Use Kubernetes?

Kubernetes is an open-source container orchestration platform designed to automate the deployment, scaling, and operation of application containers. Developed by Google and now maintained by the Cloud Native Computing Foundation, Kubernetes offers several key advantages:

  • Container Orchestration:
    • Efficiently manages the lifecycle of containers, handling deployment, scaling, and termination across machine clusters. This simplifies running applications in containers that are isolated and bundle their own dependencies.
  • Scalability:
    • Enables automatic scaling of applications up and down using simple commands, UI, or automatically based on CPU usage.
  • Load Balancing:
    • Distributes network traffic to ensure stable deployment, preventing single points of failure in your application.
  • High Availability:
    • Ensures application availability through features like automatic bin packing, self-healing, replication, and horizontal scaling.
  • Automated Rollouts and Rollbacks:
    • Allows you to define a desired state for deployed containers and change the actual state to the desired state at a controlled rate, including creating new containers, removing existing ones, and replacing all resources.
  • Service Discovery and Load Balancing:
    • Exposes containers using DNS names or their IP addresses. If traffic to containers is high, Kubernetes can load balance and distribute network traffic.
  • Storage Orchestration:
    • Automatically mounts any storage system, including local storages and public cloud providers.
  • Secret and Configuration Management:
    • Manages sensitive information like passwords, OAuth tokens, and SSH keys, allowing you to deploy and update secrets and application configurations without rebuilding container images or exposing secrets in stack configurations.

What is Container Orchestration?

Container orchestration is the automatic management of the container lifecycle, encompassing a variety of activities such as deployment, scaling, networking, and lifecycle management of containers. In other words, container orchestration refers to the process of constructing tasks of individual components and application layers.

Importance of Container Orchestration
  • Efficiency: Manages and scales a large number of containers efficiently.
  • Load Balancing: Automatically distributes load and traffic among containers.
  • High Availability: Prevents downtime by managing container replicas and replacements.
Key Components in Container Orchestration
  • Container: A lightweight, standalone executable package that includes everything needed to run software.
  • Pod: The smallest deployable unit in Kubernetes that can host one or more containers.
  • Node: A worker machine in Kubernetes, which could be either a VM or a physical machine, depending on the cluster.
  • Cluster: A set of nodes running containerized applications managed by Kubernetes.
Other Container Orchestration Tools

In addition to Kubernetes, there are tools like Docker Swarm and Apache Mesos that also provide orchestration capabilities.


2. What are Kubernetes components?

Kubernetes is a system for managing containerized applications across clusters of machines. It uses a variety of resources and components to handle various aspects of application deployment and management. Within Kubernetes, the kube-system namespace contains several important system Pods that play important roles in a Kubernetes cluster.

Control Plane Components

kube-apiserver
  • Responsible for central control of the entire Kubernetes cluster.
  • It provides Kubernetes APIs for use by internal system components as well as external users.
  • When a Pod is created, kube-apiserver processes requests and stores Pod information in the etcd database.
etcd
  • A consistent, highly available key-value store that serves as Kubernetes' backing store for all cluster data.
  • When a Pod is created, its configuration and state are stored in etcd, so the cluster state is maintained and can be recovered in the event of a failure.
kube-scheduler
  • It watches for newly created Pods that do not have assigned nodes and selects which nodes to run based on various scheduling criteria, including resource requirements, affinity specifications, data locality, and workload-to-workload.
  • After a Pod is created, kube-scheduler assigns it to the appropriate node.
kube-controller-manager
  • Runs a controller process with background threads that handle routine tasks in the cluster.
  • When creating a Pod, the relevant controller in kube-controller-manager checks whether the actual state of the Pod matches the desired state specified by the user.

Node component

kubelet
  • The kubelet running on each node in the cluster is responsible for ensuring that containers are running in Pods.
  • When a Pod is scheduled on a node, the kubelet on that node receives a request from kube-apiserver and starts the container specified in the Pod.
kube-proxy
  • It runs on each node and is a network proxy, maintaining network rules that allow network communication to Pods from network sessions inside or outside the cluster.
  • When a Pod is created, kube-proxy updates the node's network rules to allow IP forwarding to the Pod's IP address.
DNS service (ex: CoreDNS)
  • Provides a DNS service for your Kubernetes cluster, translating service and pod names into IP addresses.
  • When a Pod is created, it gets an IP address and DNS name. CoreDNS updates records to make Pods accessible via their DNS names within the cluster.
Container Runtime
  • Container runtime is software responsible for running containers.
  • Supports container runtimes such as Containerd and CRI.
Addon
  • Addon implements cluster functions using Kubernetes resources (daemonset, deployment, etc.).
  • Because it provides cluster-level functionality, the namespace resource for the add-on belongs to the kube-system namespace.

3. Kubernetes Pod creation method

  1. kubectl (Execute):

    • User executes kubectl apply -f k8s-deployment.yml.
    • Converts YAML to JSON and sends to kube-apiserver.
  2. kube-apiserver (Processing):

    • Receives deployment request.
    • Stores deployment details in Kubernetes database.
  3. etcd (Data Storage):

    • Stores configuration and state information.
    • Notifies kube-controller-manager when deployment resources are updated.
  4. kube-controller-manager (Resource Creation):

    • Creates Pod resources based on deployment's replica count.
  5. kube-scheduler (Scheduling):

    • Monitors unscheduled pods; assesses node health.
    • Selects optimal node and updates nodeName in Pod spec.
  6. kubelet (Node-Level Execution):

    • Running on each worker node.
    • Checks for and runs containers in assigned pods.
    • Executes tasks per control plane instructions.
  7. Container Runtime Interface (CRI) Daemon (Container Creation):

    • Invoked by kubelet to create containers in the pod.
  8. kubelet (Status Update):

    • Performs readiness and liveness probes.
    • Updates pod status to running if checks pass.

Reference

Clone this wiki locally