provider-kubernetes icon indicating copy to clipboard operation
provider-kubernetes copied to clipboard

Watch changes in the referenced objects

Open turkenh opened this issue 11 months ago • 1 comments

What problem are you facing?

Today, it is possible to reference k8s objects in the control plane API by with spec.references field. For example, the following manifest will read the ConfigMap named foo in the default namespace and propagate it to another cluster/namespace.

apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
metadata:
  name: foo-copy
spec:
  references:
  # Use patchesFrom to patch field from other k8s resource to this object
  - patchesFrom:
      apiVersion: v1
      kind: ConfigMap
      name: foo
      namespace: default
      fieldPath: data
    toFieldPath: data
  forProvider:
    manifest:
      apiVersion: v1
      kind: ConfigMap
      metadata:
        namespace: default
  providerConfigRef:
    name: another-cluster

This problem is that if the ConfigMap foo on the control plane changes, it takes up to the poll interval (up to 10mins by default) for it to be propagated again.

This sounds similar to https://github.com/crossplane-contrib/provider-kubernetes/issues/159 but different since here were proposing the objects that are part of the desired state. That issue wants to be aware of changes in the observed state as soon as possible by watching them.

How could Crossplane help solve your problem?

Watch changes in the referenced objects so that updates on the referenced object reconciled immediately instead of waiting for the poll interval.

turkenh avatar Mar 08 '24 09:03 turkenh

Leaving some breadcrumbs (from @sttts):

There will be similarities to Crossplane realtime compositions but this will be a lot simpler since the main controller (XRs in crossplane) does not come and go, and there is only one. So it is only about the referenced objects. In Crossplane we have many XRs, dynamically updated, and all share the composed object informers.

We don't need RegisterComposite in composedResourceInformers, but WatchComposedResources and cleanupComposedResourceInformers will be very similar. We might copy those nearly 1:1.

turkenh avatar Mar 13 '24 08:03 turkenh