Introduction to K8s Container Cloud Platform

One, Kubernetes overview

  • Kubernetes is a container cluster management system open sourced by Google in 2014. Kubernetes is referred to as K8S.
  • K8S is used for the deployment, expansion and management of containerized applications
  • K8S provides a series of functions such as container orchestration, resource scheduling, elastic scaling, deployment management, service discovery, etc.
  • The goal of Kubernetes is to make deploying containerized applications simple and efficient

1.1, Kubernetes features

Self-healing
Restart the failed container when the node fails, replace and redeploy to ensure the expected number of copies; kill the container that failed the health check, and will not process client requests until it is not ready to ensure that online services are not interrupted

Elastic Scaling
Use commands, U or based on CPU usage to automatically quickly expand and shrink application instances to ensure high availability during peak concurrency of application business; resources are recovered when business peaks are low, and services are run at minimal cost

Automatic deployment and rollback
K8S uses a rolling update strategy to update applications, updating one Pod at a time (first create and then delete) instead of deleting all Pods at the same time. If there is a problem in the update process, the changes will be rolled back to ensure that the upgrade is not affected.

Service discovery and load balancing
K8S provides a unified access entry (internal IP address and a DNS name) for multiple containers, and load balances all associated containers so that users do not need to consider container IP issues

Confidentiality and configuration management
Manage confidential data and application configuration without exposing sensitive data in the mirror, improving the security of sensitive data. And can store some commonly used configurations in K8S, which is convenient for application use

Storage orchestration
Mount external storage systems, whether from local storage, public cloud (such as ANS), or network storage (such as NFS, GlusterFS, Ceph), as part of the cluster resources, which greatly improves storage flexibility

Batch processing
Provides one-time tasks and timed tasks; meets the scenarios of batch data processing and analysis

1.3, Kubernetes cluster architecture and components (single node)

Insert picture description here

Structure analysis:

  • First of all, k8s has two accessible entrances, one is from kubectl (administrator access), and the other is from the Internet (customer access)
  • Administrators can manage k8s through kubectl instructions. First, they must pass Auth (identity verification) and be granted management permissions before they can manage k8s. API Server handles all requests.
  • API Server is the only entry for request management. Upon receiving the request, it will write the request to Etcd (distributed database, key-value pair storage, with service discovery mechanism), and then Etcd will return information to API Server (information has been Created successfully in Etcd)
  • API Server will determine which Node resource is more suitable to create a container according to the scheduler (scheduling algorithm, accounting for all Node resources), and then return the information to API Server, and API Server will write the resource node information that can create the container into Etcd , After Etcd recording is complete, return information to API Server
  • API Server will look for controller-manager (controller manager) before creating resources. Controller-manager defines the resource type (such as stateful resources or stateless resources), and then returns the information to API Server
  • API Server finds kubelet for resources to be created, kubelet completes the creation and management of the container, kubelet manages the Pod life cycle, and the pod maintains the life cycle of the container. The kubelet will issue the command to the Pod, and the Pod will issue it to the container. The container downloads the image and generates the container, and then the container exposes the relevant ports.
  • Finally, kube-proxy acts as a reverse proxy to complete the load balancing of each port. The client can access the services in the relevant container through the reverse proxy. Kubelet will return the information to the API Server, telling the API Server that the container is in the running state. , API Server writes the information to Etcd again, and Etcd will automatically update the status to running. Then when you view it through the kubectl command, you will find that the container is in the running state

1.4, K8S components

Master component

kube-apiserver
Kubernetes API, the unified entrance of the cluster, the coordinator of each component, provides interface services with RESTful API, all the addition, deletion, modification, and monitoring operations of all object resources are handed over to the APIServer for processing and then submitted to Etcd storage

kube-controller-manager
handles regular background tasks in the cluster. A resource corresponds to a controller, and ControllerManager is responsible for managing these controllers.

kube-scheduler
selects a Node node for the newly created Pod according to the scheduling algorithm. It can be deployed arbitrarily. It can be deployed on the same node or on different nodes.

Etcd
distributed key-value storage system. Used to save cluster state data, such as Pod, Service and other object information

Node component

kubelet
kubelet is the Agent of the Master on the Node node. It manages the life cycle of running containers on the machine, such as creating containers, Pod mounting data volumes, downloading secrets, and obtaining container and node status. kubelet converts each Pod into a set of containers

kube-proxy
implements Pod network proxy on Node nodes, maintains network rules and four-layer load balancing work

docker or rocket
container engine to run the container

Two, the core concept of Kubernetes

The
smallest deployment unit
of
a Pod. A collection of a set of containers. The containers in a Pod share a network namespace.
Pod is short-lived (no restart function)

Controllers
ReplicaSet: Ensure the expected number of Pod replicas
Deployment: Stateless (without own identity information) Application deployment
StatefulSet: Stateful application deployment
DaemonSet: Ensure that all Nodes run the same Pod
Job: One-time task
Cronjob: Timed task
higher level object , Deploy and manage Pod

Service
prevents Pod from losing connection.
Defines a set of Pod access policies
label: tags, which are attached to a resource for associating objects, querying and filtering
Namespaces: namespaces, and isolating objects logically.
Annotations: Annotations

Third, the deployment method of Kubernetes

3.1 、 beadm

Kubeadm is also a tool that provides kubeadm init and kubeadm join for rapid deployment of Kubernetes clusters

3.2, binary package

It is recommended to download the binary package of the distribution from the official, manually deploy each component to form a Kubernetes cluster

Guess you like

Origin blog.csdn.net/weixin_50344814/article/details/114992642