当前位置:网站首页>Kubernetes architecture that novices must know
Kubernetes architecture that novices must know
2022-06-29 22:17:00 【Docker Chinese community】

Control plane assembly
ETCD
etcd It's a fast one 、 Distributed 、 Consistent key value storage , Used as persistent storage Kubernetes Object data ( Such as pod、replication controllers, secrets, services etc. ) Backup storage for . actually ,etcd yes Kubernetes The only place to store cluster status and metadata . Only direct and etcd The components of the dialogue are Kubernetes API Server. All other components pass through API Server Indirectly read and write data to etcd.
Etcd It also implements a monitoring function , It provides an event based interface , Used to asynchronously monitor key changes . Once the key is changed , Its observer will be notified .API Server Components rely heavily on this to get notifications and send etcd Move the current state of to the desired state .
etcd Should the number of instances be odd ?
stay HA Environment , You usually run 3、5 or 7 individual etcd example , But why ? because etcd It's distributed data storage , So you can expand it horizontally , But you also need to make sure that the data in each instance is consistent , So , Your system needs to agree on the status .Etcd Used for this purpose RAFT Consensus algorithm [1].
The algorithm requires a majority of ( Or arbitration ) The cluster can enter the next state . If you only have 2 individual ectd example , If any of them fails , be etcd The cluster cannot transition to the new state , Because there is no majority , And in 3 In the case of two instances , One instance may fail and most instances can still be available .
API Server
API Server yes Kubernetes The only one with etcd Directly interacting components .Kubernetes And the client (kubectl) All other components in the must pass API Server To handle cluster status .API Server Provide the following functions :
Provide in etcd A consistent way of storing objects in . Perform validation of these objects , So that the client cannot store incorrectly configured objects , If they write directly etcd This can happen in the data store . Provide RESTful API To create 、 to update 、 Modify or delete resources . Provide optimistic concurrency locking , So in the case of concurrent updates , Changes to objects will never be overwritten by other clients . Perform authentication and authorization on requests sent by clients . It uses the plug-in to extract the user name of the client 、 user ID And the group to which the user belongs , And determine whether the authenticated user can perform the requested operation on the requested resource . If the request attempts to create 、 Modify or delete resources , execute Access control [2]. Example :AlwaysPullImages、DefaultStorageClass、ResourceQuota etc. . Implement the monitoring mechanism for the client ( Be similar to etcd) To monitor changes . This allows the scheduler and Controller Manager And other components are loosely coupled with API Server Interaction .
Controller Manager
stay Kubernetes in , The controller is a control loop that monitors the status of the cluster , Then make or request changes as needed . Each controller attempts to move the current cluster state closer to the desired state . The controller tracks at least one Kubernetes The resource type , And these objects have a canonical field that represents the desired state .
Controller example :
Replication Manager(ReplicationController Controller of resources ) ReplicaSet、DaemonSet and Job controller Deployment controller StatefulSet controller node controller service controller endpoints controller namespace controller PersistentVolume controller
The controller uses a monitoring mechanism to get change notifications . Their surveillance API Server Changes to resources and actions for each change , Whether it's creating new objects or updating or deleting existing objects . Most of the time , These operations include creating other resources or updating the monitored resources themselves , However, the use of monitoring does not guarantee that the controller will not miss any events , They also perform periodic relist operations to ensure that nothing is missed .
Controller Manager It also performs lifecycle functions , For example, create lifecycles and namespaces 、 Event garbage collection 、 End pod Garbage collection 、 Cascade delete garbage collection [3]、 Node garbage collection, etc .
Scheduler
The scheduler is a control plane process , It will pod Assign to nodes . It monitors newly created nodes that are not assigned nodes pod, And for every pod, The scheduler is responsible for the pod Find the best node to run .
Satisfy Pod The node required by scheduling is called feasible node . If there is no proper node , be pod Will remain unscheduled , Until the scheduler can place it . Once a viable node is found , It will run a set of functions to rate the nodes , And select the node with the highest score . Then it will inform API Server Information about the selected node , This process is called binding .
The selection of nodes is divided into two steps :
Filter List of all nodes for pod List of acceptable nodes that can be scheduled .( for example ,PodFitsResources The filter checks whether the candidate nodes have enough available resources to meet Pod Specific resource requests ) Yes, from the 1 Score the node list obtained in step And rank them to select the best node . If multiple nodes score the highest , Then the circulation method is used to ensure pod Deploy evenly on all nodes .
The factors to be considered in scheduling decision include :
Pod For hardware / Request for software resources ? Whether the node reports memory or disk pressure ? Whether the node has a connection with pod The node selector in the specification matches the label ? If pod The request is bound to a specific host port , Whether the port is occupied on the node ? pod Whether to tolerate the stain of nodes ? pod Whether to specify node affinity or anti affinity rules ? etc. .
The scheduler does not instruct the selected node to run pod.Scheduler All you do is through API Server to update pod Definition .API server adopt watch Mechanism notice Kubelet pod Has been scheduled . Then... On the target node kubelet Service see pod Has been scheduled to its node , Create it and run it pod The container of .
Work node component
Kubelet
Kubelet Is the agent running on each node in the cluster , It is the component responsible for all the contents running on the work node . It ensures that the container is Pod Run in .
kubelet The main functions of the service are :
By means of API Server Create a node resource in to register the node it is running . Continuous monitoring API Server Scheduled to node on Pod. Use the configured container runtime to start pod The container of . Continuously monitor running containers and their status 、 Report events and resource consumption to API Server. Run container activity detection , Restart the container when the probe fails , In the container Pod from API Server Terminate container when deleted from , And notify the server Pod Terminated .
kube-proxy
It runs on each node , And make sure one pod Can be with another pod dialogue , A node can talk to another node , One container can communicate with another container, etc . It is responsible for monitoring API Server To understand Service and pod Change of definition , To keep the whole network configuration up to date . When one Service By multiple pod when ,proxy Will be in these pod Load balancing between .
kube-proxy The reason why it got its name is , Because it is an actual proxy server , Used to accept connections and proxy them to Pod, The current implementation uses iptables or ipvs Rules redirect packets to randomly selected backend Pod, Instead of passing them through the actual proxy server .
When creating a service , A virtual... Will be assigned immediately IP Address . API Server Notifies the running on the work node kube-proxy The agent has created a new service . Every kube-proxy By setting iptables Rules make services addressable , Ensure that every service is blocked IP/ Port pair , And modify the target address to support the service pod One of . monitor API Server Changes to the service or its endpoint objects .
Container runtime
Focus on running containers 、 Set the namespace and container cgroup The container runtime of is called the low-level container runtime , Focus on format 、 Unpack 、 Manage and share images And provide API The container runtime that meets the needs of developers is called advanced container runtime ( Container engine ).
When the container is running, it is responsible for :
If local is not available , Then pull the container image required by the container from the image registry . Extract the image to the copy file system on write , All container layers overlap each other to create a merged file system . Prepare the container mounting point Set metadata from container image , For example, covering CMD、 From user input ENTRYPOINT、 Set up SECCOMP Rules etc. , To ensure that the container operates as expected . Change the kernel to assign some sort of isolation to the container , For example, the process 、 Networks and file systems . Remind the kernel to allocate some resource restrictions , Such as CPU Or memory limit . Call the system (syscall) Pass to the kernel to start the container . Make sure SElinux/AppArmor Set up correctly .
Reference material
RAFT Consensus algorithm : https://www.geeksforgeeks.org/raft-consensus-algorithm/
[2]Access control : https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/
[3]Cascade delete garbage collection : https://kubernetes.io/docs/concepts/architecture/garbage-collection/
《Kubernetes and Docker What does it matter ?》
《 Teach you how to quickly query and select the image of the network warehouse tag》
《Docker Mirror advanced : Understand the technical principle behind it 》
《 Teach you how to modify the running container port mapping 》
《k8s Learning notes : Introduce & Get started 》
《k8s Learning notes : Scale up & to update 》
《Docker Basic usage and command help 》
《 stay K8S To build Redis colony 》
《 Gray scale deployment 、 Rolling deployment 、 Blue and green deployment 》
《Kubernetes(k8s) Analysis of underlying network principle 》
《 In a container environment Node.js Memory management for 》
《MySQL Quickly create tens of millions of test data 》
《Linux And Unix What's the difference ?》
《 On several common RAID Similarities and differences 》
《Git note - Programmers have to master Git》
《 What an old driver must know MySQL standard 》
《Docker in Image、Container And Volume Migration 》
《 comic | How to use Kubernetes Get it done CICD》
《 To the front end Docker Practical course 》
《Linux Operating system knowledge map 2.0, it will work 》
《16 A concept to get you started Kubernetes》
《IT Old bird of the industry , I have something to say to you 》
《HTTPS Why is it safe ? Let's talk about his underlying implementation ?》
disclaimer : The content of this article comes from the Internet , The contents are for reference only . Reprinted only for the purpose of learning and communication , If you inadvertently infringe upon your legitimate rights and interests , Please contact Docker The Chinese community !


边栏推荐
- Go learning (IV. interface oriented)
- Three development trends of enterprise application viewed from the third technological revolution
- 动态规划学习(持续更新)
- 5-minute quick start pytest testing framework
- 生产环境AIX小机报错B6267342问题处理
- Which securities to choose for securities account opening? In addition, is it safe to open an account online now?
- 状态管理 利用Session限制页面访问 只有通过登录验证SessionLogin.aspx才能访问Session.aspx
- Matplotlib histogram
- Mysql入库不了表情符号怎么办
- Reading notes on how to connect the network - Web server request and response (V)
猜你喜欢

数论-整除分块

Golang operation NSQ distributed message queue

Dynamics 365online lookup lookup field multiple selection

The logic behind the three whys encountered in technical communication

一文2500字手把手教你使用jmeter进行分布式压力测试【保姆级教程】
A mysql IBD file is too large processing record

Hardware development notes (VIII): basic process of hardware development, making a USB to RS232 module (VII): creating a basic dip component (crystal oscillator) package and associating the principle

Autodesk Revit 2023 software installation package download and installation tutorial

ASP动态创建表格 Table

Layer 3 loop brought by route Summary - solution experiment
随机推荐
The soft youth under the blessing of devcloud makes education "smart" in the cloud
Data mining review
动态规划学习(持续更新)
每日刷题记录 (八)
期末实训 简单通讯录 c语言
请教一下,CDC2.2.1可以同时监听多个pgsql 的库吗?
R language plot visualization: plot visualization box graph and several box plots of multiple classification variables
C. Where‘s the Bishop?
Layer 3 loop brought by route Summary - solution experiment
jfinal中如何使用过滤器监控Druid监听SQL执行?
Deep learning remote sensing data set
cout 不明确问题
软件快速交付真的需要以安全为代价吗?
Mysql入库不了表情符号怎么办
As for the domestic Kirin system running QT, it can be run on the command line but cannot be run by double clicking (no response)
从第三次技术革命看企业应用三大开发趋势
泰山OFFICE技术讲座:一行中所有元素高度相同
软件快速交付真的需要以安全为代价吗?
Divide the bonus pool of 10million + million yuan, and empower developers in the 2022 shengteng AI innovation competition
细说GaussDB(DWS)复杂多样的资源负载管理手段