Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get required fields from a list of resources belonging to same Kind #156

Open
AmitKumarDas opened this issue Oct 19, 2020 · 1 comment
Labels

Comments

@AmitKumarDas
Copy link

AmitKumarDas commented Oct 19, 2020

ProblemStatement: As a SRE admin, I want to fetch required fields from all resources belonging to the same Kind. For example, I want to fetch spec.replicas from all Deployments with labels my-app: nginx and running in ent namespace.

@AmitKumarDas
Copy link
Author

AmitKumarDas commented Oct 19, 2020

Draft design

kind: Recipe
spec:
  tasks:
  - name: list-replicas-from-deployment
    list:
      state:
        kind: Deployment
        metadata:
          namespace: ent
          labels:
            my-app: nginx
        spec: 
          replicas: ?
  • Above when applied will result in below
kind: Recipe
spec:
  # removed for brevity
status:
  tasks:
    list-replicas-from-deployment:
      objectList:
      - kind: Deployment
        metadata:
          name: abc
          namespace: ent
          labels:
            my-app: nginx
        spec: 
          replicas: 2
      - kind: Deployment
        metadata:
          name: zef
          namespace: ent
          labels:
            my-app: nginx
        spec: 
          replicas: 3

NOTES

  • We might need to join the fields from multiple tasks
kind: Recipe
spec:
  tasks:
  - name: list-replicas-from-deployment
    list:
      join:
        type: Parent
      state:
        kind: Deployment
        metadata:
          namespace: ent
          labels:
            my-app: nginx
        spec: 
          replicas: ?
  - name: list-cluster-ip-from-service
    list:
      join:
        type: Child
        when: 
        - NameMatch
        - NamespaceMatch
        - AllLabelsMatch
      state:
        kind: Service
        metadata:
          namespace: ent
          labels:
            my-app: nginx
        spec: 
          clusterIP: ?
  • Above would extract the corresponding clusterIP
  • Since join is enabled it would match against corresponding Parent task output
  • If match is successful clusterIP is made available in the list-replicas-from-deployment output
  • If no match then clusterIP is made available in the list-cluster-ip-from-service output
  • NOTE: Task with join.type as Parent should appear before all Child tasks
  • NOTE: There should be only one task with join.type as Parent
  • NOTE: There can be multiple tasks with join.type as Child

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant