简体   繁体   English

变异准入 webhook 静态命名空间选择器

[英]mutating admission webhook static namespaceselector

Does anyone know if there is a way to define static selectors based on the namespace name instead of label selectors?有谁知道是否有办法根据命名空间名称而不是标签选择器来定义静态选择器? The reason is that some of the namespaces are created by an operator and I don't have any control over the labels.原因是一些命名空间是由操作员创建的,我对标签没有任何控制权。

Thanks Essey谢谢埃西

Seems no, never heard, never found anything like that.似乎没有,从未听说过,从未发现过类似的东西。

As per MutatingWebhookConfiguration docs property namespaceSelector has a type LabelSelector [meta/v1] that supports根据MutatingWebhookConfiguration docs属性namespaceSelector有一个类型LabelSelector [meta/v1]支持

.matchExpressions
matchExpressions is a list of label selector requirements. The requirements are ANDed.

and

.matchLabels
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.

And in the end everything is dependent on labels .最后一切都取决于标签

For sure you saw these examples你肯定看过这些例子

Each namespace has the so-called well-known label kubernetes.io/metadata.name每个命名空间都有所谓的知名标签kubernetes.io/metadata.name

So your namespaceSelector can be something like:所以你的namespaceSelector可以是这样的:

namespaceSelector:
  matchExpressions:
    - key: kubernetes.io/metadata.name
      operator: "In"
      values:
        - "staging"
        - "demo"

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM