[K8s] Kubernetes understand architecture

  Taking the time to learn a bit would be similar resource management, task scheduling Kubernetes, feel and cluster areas such as Big Data, briefly summarize memo.

【concept】

  Kubernetes is an industrial grade container orchestration platform, a bit long word, said on behalf of common K8s.

  Its main features are:

  • Scheduling : For example, when deploying Pod, Pod deployed to the machines more idle nodes.
  • Automatic Recovery : For example, machine health check node, the migrated Pod node on the failed machine to machine normal node.  
  • Elastically stretchable : e.g., traffic load check, when the CPU / memory usage is too high, or the like Pod service response time is too long when the preset pre-conditions are satisfied, automatic expansion.

 PS:   

  Pod is a collection of very closely related set of containers, for example between containers need for direct file exchange, share some Namespace, there are very frequent RPC call between and so on. Pod is K8s atoms scheduling unit, instead of the container.

 

[Architecture] official

【understanding】

  The official figure is K8s technical architecture, in fact, before the technical architecture, there should be a more simplified logic architecture K8s the foundation. Output understood as follows:

  

  • etcd

  It is a distributed storage component, used to store all of the cluster state, also has event subscription and listening ability Leader elections.

  Subscribe to events and listeners: the various other components communicate with each other API calls are not done, but the state is written etcd, other components monitor changes in the state by subscribing etcd, and then do follow-up treatment, and then once again to update the data is written etcd.

  Leader election: components such as Scheduler, To do achieve high availability, by etcd from multiple (usually three) examples of which elected to do a Master, others are Standby.

 

  • API Server

  Above etcd not be accessed directly, but delegates after the visit by API Server. API Server API Gateway is equivalent, it will call the package etcd interface is standard RESTFul API.

  此外,API Server还实现了一些附加功能,例如身份认证、缓存等。

 

  • Controller Manager:

  实现任务调度。直接请求Kubernetes做调度的都是任务,例如Deployment、Deamon Set或者Job,每一个任务请求发送给Kubernetes 之后,都是由 Controller Manager 来处理的。

  每一种任务类型对应一个 Controller Manager,例如:Deployment对应Deployment Controller,ReplicaSet对应ReplicaSet Controller。

 

  • Scheduler:

  实现资源调度。Controller Manager会把任务对资源Pod的要求,写入到etcd。Scheduler监听到有新的资源Pod要求被调度,会根据整个集群的各个节点的资源情况,将Pod分配到较为空闲合适的节点上。

 

  • Kubelet:

  是一个Agent,运行在每一个节点上,它会监听etcd中的Pod的信息,发现有分配给它所在节点的Pod需要运行,就在节点上运行相应的Pod,并且把状态更新回到etcd。

 

  • Kubectl:

  是一个提供给用户的命令行工具,用户通过它调用API Server,发送请求写入状态到etcd,或者查询etcd中的状态。

 

【举例】

   假如要运行一个多个实例的Nginx,那么在 Kubernetes内部,流程如下: 

  1. 通过 kubectl 命令行,创建一个包含Nginx 的Deployment对象。kubectl会调用 API Server 往 etcd里面写入一个Deployment 对象。
  2. Deployment Controller监听到有新的 Deployment 对象被写入,就获取到对象信息,根据对象信息来做任务调度,创建对应的 Replica Set 对象。
  3. Replica Set Controller 监听到有新的对象被创建,也读取到对象信息来做任务调度,创建对应的 Pod 。
  4. Scheduler监听到有新的Pod被创建,读取到 Pod 对象信息,根据集群状态将 Pod 调度到某一个节点上,然后更新 Pod(内部操作是将 Pod 和节点绑定)。
  5. Kubelet 监听到当前的节点被指定了新的 Pod,就根据对象信息运行 Pod。

Guess you like

Origin www.cnblogs.com/wwcom123/p/10963136.html