kubernetes - 如何使用 Kubebuilder-v3/operator-sdk 发送事件

标签 kubernetes operator-sdk kubebuilder

Kubebuilder V3 documentation解释说它讨论了“如何将多个事件批处理到单个协调调用中”。但是,我在本文档中找不到任何有关事件管理的信息。

您能否提供有关如何使用 Kubebuilder-v3/operator-sdk 发送事件的信息/代码示例?

最佳答案

This part官方文档应该可以回答您的问题:

This business logic of the Controller is implemented in the Reconcile function. This function takes the Namespace and Name of a ContainerSet, allowing multiple Events to be batched together into a single Reconcile call. The function shown here creates or updates a Deployment using the replicas and image specified in ContainerSet.Spec. Note that it sets an OwnerReference for the Deployment to enable garbage collection on the Deployment once the ContainerSet is deleted.

  1. Read the ContainerSet using the NamespacedName
  2. If there is an error or it has been deleted, return
  3. Create the new desired DeploymentSpec from the ContainerSetSpec
  4. Read the Deployment and compare the Deployment.Spec to the ContainerSet.Spec
  5. If the observed Deployment.Spec does not match the desired spec - Deployment was not found: create a new Deployment - Deployment was found and changes are needed: update the Deployment

在那里您还可以找到代码示例。

关于kubernetes - 如何使用 Kubebuilder-v3/operator-sdk 发送事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70529847/

相关文章:

go - 在协调功能中检测规范更新

kubernetes - 使用 operator-sdk 生成 'oneOf' 属性

docker - 不使用operator-sdk直接构建operator镜像?

amazon-web-services - k8s controller watch other controller CR

kubernetes - 如何在 Helm 中使用环境/ secret 变量?

kubernetes - 安排 cron 工作永远不会发生?

spring - Kubernetes Secret 和 Spring Boot 配置

kubernetes - 有什么办法可以在持久卷声明中包含弹性卷吗?

kubernetes - kubebuilder/controller-runtime 是否仍然保留

kubernetes - Kubebuilder 谓词跳过某些命名空间