feat: get required fields from a list of resources belonging to same Kind
AmitKumarDas opened this issue · comments
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.
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