Skip to content

add regex support for node names or labels #5

@m-yosefpor

Description

@m-yosefpor

There is another node label operator by redhat (https://github.com/openshift-kni/node-label-operator) which supports node name patterns (regex) for labeling, however it doesn't support taints. We need to taint and label nodes based on their name, e.g:

node-infra-0
node-infra-1

It would be really nice if we could have a selector with regex match, like a mixture of these operators to have Labeler objects such as:

apiVersion: labeler.barpilot.io/v1alpha1
kind: Labeler
metadata:
  name: spare-prefer-taint
  labels:
    operator: node-labeler-operator
spec:
  nodeNamePatterns:
    - "node-infra-.*"
  nodeSelectorTerms:
  - matchExpressions:
    - key: kubernetes.io/os
      operator: In
      values:
      - "linux"
   merge:
    labels:
      node-role.kubernetes.io/infra: "true"
    taints:
    - effect: NoExecute
      key: node-role.kubernetes.io/infra

Which selects all nodes which match nodeSelectorTerms AND then filters the ones which match one of nodeNamePatterns, and only apply the labels and taints to those.

Another more general method is to have this regex matching for labels, with introducing a new seletor operator such as key: "kubernetes.io/host", operator: "match", values: ["somepattern.*"]

however as it violates the standard of matchExpressions of k8s, I think this latter method is not good, and the first one is more clear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions