简体   繁体   English

Controllers 如何在 Kubernetes 集群中创建资源?

[英]How Controllers create resources in a Kubernetes cluster?

I am creating a K8s object creation workflow, and I want to be sure everything is correct.我正在创建一个 K8s 对象创建工作流程,我想确保一切都是正确的。 There is this nice flow in Heptio blogs, but controller manager is missing, which is where my doubts are. Heptio 博客中有这个不错的流程,但缺少控制器管理器,这就是我的疑虑所在。

If we read K8s docs, Controller Manager is always described as this loop that watches on the desired state of the cluster, and moves all the necessary strings to bring the current state into that (desired) state.如果我们阅读 K8s 文档, Controller Manager总是被描述为这个循环,它监视集群的期望状态,并移动所有必要的字符串以将当前状态带入该(期望)状态。

Fair enough, but we also know that kubelet has the container runtime, so kubelet creates containers or pods.很公平,但我们也知道 kubelet 具有容器运行时,因此 kubelet 创建容器或 pod。 We also know that kube-proxy makes the necessary changes in the iptable rules, so services will work properly.我们也知道 kube-proxy 对 iptable 规则进行了必要的更改,因此服务将正常工作。 And so on.等等。 So how does exactly controller manager works?那么控制器管理器究竟是如何工作的呢?

To my knowledge, there are these processes (Informers/Watchers for each resource; not necessarily 1:1) that watch on resource changes through the API-Server, and add jobs to a Queue, that are consumed by the Worker node components.据我所知,有这些进程(每个资源的通知者/观察者;不一定是 1:1)通过 API-Server 监视资源变化,并将作业添加到队列中,由 Worker 节点组件使用。 Would appreciate if anyone could correct me, if I'm wrong.如果我错了,如果有人可以纠正我,我将不胜感激。

I think you are right about how the controller manager works.我认为您对控制器管理器的工作方式是正确的。 To my best knowledge, controller manager in Kubernetes is a set of controllers such as node controller, pod controller and Deployment controller.据我所知,Kubernetes 中的控制器管理器是一组控制器,例如节点控制器、pod 控制器和部署控制器。 Each controller list/watch specific resource and defines some callback functions like update, add and delete.每个控制器列出/观看特定资源并定义一些回调函数,如更新、添加和删除。 When resource changes the controller call corresponding functions to bring the system to the desired state.当资源发生变化时,控制器调用相应的函数使系统进入所需的状态。 You can even define your own CRD and corresponding controller to manage your resource, which is a very strong and flexible tool.您甚至可以定义自己的 CRD 和相应的控制器来管理您的资源,这是一个非常强大和灵活的工具。 The sample controller might be useful.示例控制器可能很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用ruby为Kubernetes集群资源创建单元测试 - How to create unit test using ruby for Kubernetes cluster resources Kubernetes 中的对象、资源和控制器 - Objects, Resources and Controllers in Kubernetes Kubernetes 资源和控制器 - kubernetes resources and controllers 如何计算 Kubernetes 集群的节点可分配资源? - How to calculate Node Allocatable Resources for Kubernetes cluster? 如何在 Kube.netes 集群级别查找可用资源? - How to find available resources in a Kubernetes Cluster level? 如何在Kubernetes集群中创建用户? - How to create a user in a Kubernetes cluster? 如何从集群中正在运行的 Spring Boot 应用程序中动态创建 Kubernetes 资源 - How to dynamically create Kubernetes resources from within a running spring boot application in the cluster 如何在kubernetes集群中的所有资源上执行资源限制/请求? - How to enforce Resource Limits/Requests on all resources in a kubernetes cluster? 一个 kubernetes 集群可以处理多少个 CR(自定义资源)? - How many CRs (Custom Resources) can a kubernetes cluster handle? 如何创建 kube.netes 自定义资源或自定义插件? - How to create kubernetes custom resources or custom plugin?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM