2

K8s | 控制器模型是怎样的?

 2 years ago
source link: https://jiac3366.github.io/2021/11/17/Kubernetes/%E6%8E%A7%E5%88%B6%E5%99%A8%E6%A8%A1%E5%9E%8B%E6%98%AF%E6%80%8E%E6%A0%B7%E7%9A%84%EF%BC%9F/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

+c编程手记

Guangzhou, China
  • CRD 就是一个专门用来定义 Schema 的一个特殊的 API 对象

  • 控制循环——“ReconcileLoop”(调谐循环)或者“Sync Loop”(同步循环)

  • 被控制对象的定义,则来自于一个“模板”。

    控制循环最后的执行结果,要么创建、更新一些Pod(或者其他的 API 对象、资源),要么删除一些已经存在的 Pod(或者其他的API 对象、资源)。

    • Deployment 这样的一个控制器,上半部分是控制器定义(包括期望状态),下半部分的是被控制对象的模板

    • eg: Deployment 里的 template 字段(PodTemplate(Pod 模板)),被这个 Deployment 管理的 Pod 实例,都是根据这个template 字段的内容创建的

      • Kubernetes 使用的这个“控制器模式”,跟我们平常所说的“事件驱动”,有什么区别和联系吗?

        • 相当于select和epoll的区别

        • 事件往往是一次性的,如果操作失败比较难处理,但是控制器是循环一直在尝试的,更符合kubernetes声明式API,最终达到与声明一致

      • 控制器主动获取pod状态,在这个集群中,有那么多pod,某个pod在某一时刻状态有变,怎样及时通知到控制器呢?informer机制


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK