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

How to Sync Custom Resource Fields with Referenced Resources Dynamically in Kopf? #1152

Open
luispina-ferreira opened this issue Dec 16, 2024 · 0 comments
Labels
question Further information is requested

Comments

@luispina-ferreira
Copy link

luispina-ferreira commented Dec 16, 2024

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?

@luispina-ferreira luispina-ferreira added the question Further information is requested label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant