K8S basic concepts

  • With Kubernetes you can:
    • Rapid Deployment of Applications
    • Rapid application expansion
    • Seamlessly integrate new application features
    • Saves resources and optimizes the use of hardware resources

Cluster components

Master node Component

  • Kube-apiserver, Kubernetes API, is the unified entrance of the cluster, component coordinator, RESTful API to provide interface services, all object resources add, delete, change, check and monitoring operations are handed to API Server processing and then handed to Etcd storage.
  • Kube-controller-manager handles common background tasks in a cluster. Each resource corresponds to a controller. ControllerManager is responsible for managing these controllers.
  • Kube-scheduler selects a Node for the newly created Pod based on the scheduling algorithm.
  • Etcd is a key value database with both consistency and high availability, which can be used as a background database to store all the cluster data of Kubernetes. Object information, such as Pod and Service.

Node Node component

  • Kubelet: Kubectl is the agent of master on node node, managing the declaration cycle of the local running container, such as creating container, Pod mounting data volume, downloading secret, obtaining container and node state, etc. Kubelet transforms each POD into a set of containers that send instructions to docker to manage docker containers.
  • Kube-proxy: Implement POD network proxy on node node, maintain network rules and four-layer load balancing (manage docker container network).
  • Docker or Rocket: Container engine, runs containers.

Pod

  • Minimum deployment unit
  • A POD can have one or more containers (container groups)
  • A collection of containers
  • Containers in a POD share a network namespace
Controllers

Controller, control POD, start, stop, delete POD

  • ReplicaSet: Ensures the expected number of POD replicas
  • Deployment: Stateless application Deployment
  • StatefulSet: stateful application deployment
  • DaemonSet: Ensure that all nodes run the same POD
  • Job: one-off task
  • Cronjob: scheduled task

Service

  • Associating a group of PODS to provide a unified entrance, even if the POD address changes, the unified entrance will not change, to ensure that the user access is not affected.
  • Define an access policy for a set of PODS.
  • The Labels selector, unlike Name and UID, does not need to be unique. In general, we expect many objects to have the same tag. Labels Selectors make it easy for clients/users to identify a set of objects. The label selector is a core part of Kubernetes.

A process initiated by a container

  • The client sends a request to the API Server, namely kubectl → API Server
  • When the API Server receives the request, it sends a directive to the Scheduler, namely, API Server→ Scheduler
  • Scheduler searches for a node (e.g., node /node1) among several nodes at the back end, i.e. Schedule → (find node node) node /node
  • After the scheduler finds the node, the scheduler returns the result to the API Server, namely scheduler→API Server
  • When the API Server receives the node returned by the Scheduler, it passes it to the Controller Manager, namely, API Server → Controller Manager
  • The Controller Manager sends an instruction message to the selected node (such as node /node1), namely Controller →kubectl
  • When kubectl receives a message from the controller, it sends instructions to the localhost Docker to start a container (pod), i.e. Kubectl → (local) Docker

Ali Cloud container image service

Run your own Etcd cluster to do service registration and discovery

  • etcd-0

Etcd --name etcd-0 --initial-advertise-peer-urls http://etcd-0:2380 --listen-peer-urls http://0.0.0.0:2380 --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://etcd-0:2379 --initial-cluster etcd-0=http://etcd-0:2380,etcd-1=http://etcd-1:2380,etcd-2=http://etcd-2:2380 --initial-cluster-state new

Add the Pod tag, then create the Service to select the tag by SelectorCreate a Service

  • etcd-1

Etcd --name etcD-1 --initial-advertise-peer-urls http://etcd-1:2380 --listen-peer-urls http://0.0.0.0:2380 --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://etcd-1:2379 --initial-cluster etcd-0=http://etcd-0:2380,etcd-1=http://etcd-1:2380,etcd-2=http://etcd-2:2380 --initial-cluster-state new

  • etcd-2

Etcd --name etcD-2 --initial-advertise-peer-urls http://etcd-2:2380 --listen-peer-urls http://0.0.0.0:2380 --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://etcd-2:2379 --initial-cluster etcd-0=http://etcd-0:2380,etcd-1=http://etcd-1:2380,etcd-2=http://etcd-2:2380 --initial-cluster-state new

  • The final result

Finally, the etCD service can associate any Pod and then manually modify the selector in YamLFinally, you can access the cluster…….. through the domain name etcd