mayadata-io / d-operators

Declarative patterns to write kubernetes controllers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: add/remove labels to resources of same kind

AmitKumarDas opened this issue · comments

ProblemStatement: As a SRE admin, I want to add or remove labels against resources based on resource names or resource labels

Draft Design

kind: Recipe
spec:
  tasks:
  - applyLabels:
      labels:
        app: dope
      # optional include
      include:
      - node1
      - node2
      # optional exclude
      exclude:
      - node3
      state:
        kind: Node
        metadata:
          # optional label selector
          labels:
            arch: amd64

NOTE:

  • step 1 - state will select all possible nodes based on its metadata.labels (if any)
  • step 2 - include will filter from list due to step 1
    • if include is nil then there will not be any filtering
  • step 3 - exclude will exclude from list due to step 1
    • if exclude is nil then there will not be any filtering
  • include & exclude should not be used together
  • final step
    • app: dope will be set against the final list
    • if step 1 list contain resource(s) with app: dope & its not present in include then app:dope will be unset from the resource