I'm using Metacontroller to implement a Kubernetes operator.
My problem is the following:
status.observedGeneration
field is getting updated continuously (from what I understand that means the resource was recreated).The composite controller documentation (specifically the response documentation) suggests that if there are no changes in the returned parent status or in the children collection, Metacontroller should stop calling the sync hook.
I additionally removed spec.resyncPeriodSeconds
and spec.parentResource.revisionHistory
from the composite controller manifest (to not trigger any calls to the sync hook due to timer events or changes to the parent's status
field) .
Sadly, none of this worked. How can I tell Metacontroller to stop calling the sync hook and stop to create the resource?
You probably need to enable the "status" subresource for your CRD: https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#status-subresource
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: myresource
spec:
...
subresources:
status: {}
Without that, Metacontroller will treat status updates as normal resource updates which in turn creates a new .metadata.resourceVersion
/ .metadata.generation
because Metacontroller always adds an updated .status.observedGeneration
field.
I have created an issue for this: https://github.com/GoogleCloudPlatform/metacontroller/issues/176
Hopefully this will make this situation more obvious in the future.