-
-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Keywords
No response
Problem
How can we implement the scenario of one CR field in sync with another CR field?
I am building an operator using Kopf, and I need to monitor and react to changes in other resources (e.g., Deployments, Services, ConfigMaps) referenced by my custom resource. At first, I considered manually looking up the fields and implementing the synchronization logic. However, this approach is not truly dynamic and requires additional overhead to ensure synchronization between the different resources.
For example, I wanted to have a MyAppCRD referencing Deployments, Services, or other Kubernetes resources, as shown below:
apiVersion: myapp.example.com/v1
kind: MyAppCRD
metadata:
name: my-application
spec:
deploymentRef:
name: my-deployment
namespace: default
serviceRef:
name: my-service
namespace: default
In this case, I need to:
- Track changes to the Deployment and Service objects referenced in the deploymentRef and serviceRef fields.
- Extract specific fields (e.g., labels, status conditions, annotations) from these referenced resources without having to perform complex and frequent API calls to the Kubernetes API.
Is there a better way to achieve this? For instance, is there a mechanism to create a real reference system between resources, enabling automatic change detection and efficient synchronization?