- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们有一个 k8s 运算符(基于 kubebuilder),它按预期工作,现在我们需要支持监听集群上的 secret 。
以下代码正在运行,但是我收到了集群中所有 secret 的事件,该事件效率不高,
我想要仅针对特定 secret 获取事件,假设具有特定标签/注释
的 secret ,我们该怎么做?
func (r *InvReconciler) SetupWithManager(mgr ctrl.Manager) error {
manager := ctrl.NewControllerManagedBy(mgr).
For(&corev1alpha1.Inv{}, builder.WithPredicates(predicate.Or(predicate.GenerationChangedPredicate{}, predicate.AnnotationChangedPredicate{}))).
WithOptions(controller.Options{
})
manager = manager.Watches(&source.Kind{Type: &v1.Secret{}}, handler.EnqueueRequestsFromMapFunc(func(a client.Object) []reconcile.Request {
return r.secretHandler.GetSecret(a.GetNamespace(), a.GetName())
}))
return manager.Complete(r)
}
这就是函数
func (secretReq secretHandler) GetSecret(namespace string, name string) []reconcile.Request {
fmt.Println("secret is: ", namespace, "--", name)
return nil
}
让我们说如下 secret ,并且仅针对此 secret (带有标签 foo: bar
),我将在创建或修改它时获取事件
apiVersion: v1
kind: Secret
metadata:
labels:
foo: bar
name: mysecret
namespace: dev
type: Opaque
data:
USER_NAME: YWRtaW4=
PASSWORD: dGVzdBo=
在收到事件后,我不会谈论 if 语句
,因为它已经带来了集群中的所有 secret 事件。
最佳答案
根据这个github源,您应该能够使用 EnqueueRequestForObject
选择特定对象(例如 secret )。但是,(目前)不可能仅监视特定的 secret CRUD 更改。
EnqueueRequestForObject to watch for your CRD resource changes. Inyour CRD reconciler, you'd fetch all of the TLS secrets using a labelselector based on the search definition and then run your merge logicwith the matched secrets.
EnqueueRequestFromMapFunc to watch forsecret changes and trigger a reconcile of one or more CRs. In yourmapper function, you'd fetch all of the CRs. For each CR that has asearch definition that matches the passed in secret, you'd create anew reconcile.Request for the CR, and return the list of requests,which would trigger your CRD reconciler for each CR that matched.
最干净的方法是使用标签选择器,然后将结果与现有代码合并。 post 中给出了使用标签选择器的示例。 :
func GetSecret(version string) (retVal interface{}, err error){
clientset := GetClientOutOfCluster()
labelSelector := metav1.LabelSelector{MatchLabels: map[string]string{"version":version}}
listOptions := metav1.ListOptions{
LabelSelector: labels.Set(labelSelector.MatchLabels).String(),
Limit: 100,
}
secretList, err := clientset.CoreV1().Secrets("namespace").List(listOptions)
retVal = secretList.Items[0]
return retVal, err
}
关于azure - 监视特定对象的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73884118/
我需要记录在网页上执行的事件。 例如。填写登记表。 记录器应捕获关键字条目和在页面上执行的点击,并在请求时回放。同时记录器还应该捕获生成事件的实际元素。说当我在 firstName 中键入 记录器应
我是一个 Jest 新手,我正在为我的 React 应用程序编写单元测试,该应用程序使用 redux 并使用 Typescript 编写。 我的容器组件包含这段代码: const mapDispatc
我想将一些批处理类型的作业从 cron 转移到 Monit,但正在努力让它们正常工作。这些脚本通常每天运行一次,但有时必须在当天晚些时候重新运行。目标是利用 monit 和 m/monit 前端重新运
我正在尝试测试一个组件调用 detectChanges上面注入(inject)了ChangeDetectorRef 我已经逐步完成了代码,它肯定被调用了,但似乎我在组件和测试中得到了不同的 Chang
我想知道是否有一种很好的方法来监视 SharePoint 上的文档库的更改(添加新文件、更改/ checkin 文件、删除文件等) 基本上,什么System.IO.FileSystemWatcher在
是否可以监视 R 正在使用或已用于调用函数的内存量?例如,我有一个任意函数,例如: smallest.sv <- function(){ A <- matrix(rnorm(1e6), 1e3);
这是一个简单的问题,但令人费解...... Azure 服务中是否有统计数据来监控数据工厂被访问的次数? 那么,举个例子,如果一个自动化系统被设置为通过恶意意图耗尽对 ADF 进行持续的 API 调用
Kafka提供了监控当前偏移量和最新偏移量的能力。同样,azure eventhub是否公开任何api来持续监视分区的当前偏移量和最新可用偏移量? 最佳答案 扩展上述答案,您可以看到两种方式的偏移。
是否有系统 View 或 DMV 记录我的数据仓库恢复和暂停的时间以及执行恢复和暂停的帐户?我环顾四周,似乎找不到具有开/关时间戳的 View 。或者甚至是显示放大和缩小的历史时间戳的 View 。
我一直在研究Microsoft Azure 事件中心。我的目标是找到一种提供自动可扩展性的方法。这是一项实验性工作,我实际上只是想知道我可以使用 Azure 事件中心做什么。我无法访问 Azure 平
我有一个在 azure 中运行的辅助角色。 我正在使用标准跟踪诊断,我可以使用 Visual Studio 中的服务器资源管理器查看该诊断。 但是,它很难涉水,速度很慢等等。 谁能推荐一个插件、工具、
我们将 Azure Function 与 Node.js 结合使用。 在Azure门户UI中,在每个函数调用日志列表旁边(在“监视器”选项卡中),我们看到两个计数器:“最近成功计数”和“最近错误计数”
是否有系统 View 或 DMV 记录我的数据仓库恢复和暂停的时间以及执行恢复和暂停的帐户?我环顾四周,似乎找不到具有开/关时间戳的 View 。或者甚至是显示放大和缩小的历史时间戳的 View 。
我一直在研究Microsoft Azure 事件中心。我的目标是找到一种提供自动可扩展性的方法。这是一项实验性工作,我实际上只是想知道我可以使用 Azure 事件中心做什么。我无法访问 Azure 平
我有一个在 azure 中运行的辅助角色。 我正在使用标准跟踪诊断,我可以使用 Visual Studio 中的服务器资源管理器查看该诊断。 但是,它很难涉水,速度很慢等等。 谁能推荐一个插件、工具、
是否可以获取 channel 消息的副本? (而不是从 channel 接收和删除消息) 这个想法是记录一个 channel 的消息。 最佳答案 Is it possible to get copy
我正在尝试使用 Mockito监视路径 em> dirSpy = spy(Files.createTempDirectory(DIR_NAME)); 我收到一条错误消息 Mockito cannot
我的组件具有以下功能: updateTransactions() { let notes = this.createNotes() let delTransactions = th
我想测试一些在 React 组件的 componentDidMount 生命周期方法中调用的自定义方法。 componentDidMount() { getData().then(res
我的 $scope 中有一个对象,其中包含一些属性,例如: $scope.content = { name : 'myname', description : 'mydescrip
我是一名优秀的程序员,十分优秀!