Get previous custom resource version on update #279
-
I might be missing something or I didnt got the concept of how I should work with this. However, I have a custom resource and I want to know what changed against the previous version to execute proper actions. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hey @Crespalvaro |
Beta Was this translation helpful? Give feedback.
-
Hey @Crespalvaro However as @erin-allison pointed out, this is not the general idea of the reconciliation loop in the operator pattern. You should always check if the given state in the cluster matches the one that is described by the entity. Now when I'm thinking about, the differentiation between "Created" and "Updated" is useless, because one should always check the whole state of the entity. When I created the SDK, I thought this difference matters ¯\_(ツ)_/¯ |
Beta Was this translation helpful? Give feedback.
Hey @Crespalvaro
I understand what you mean. It is theoretically possible. There are Kubernetes metadata fields that allow you to do such things (more or less). For example, when you apply the CRD with
kubectl apply
, the last used configuration of the entity is stored in an annotationkubectl.kubernetes.io/last-applied-configuration
. It contains the last json that was applied.However as @erin-allison pointed out, this is not the general idea of the reconciliation loop in the operator pattern. You should always check if the given state in the cluster matches the one that is described by the entity.
Now when I'm thinking about, the differentiation between "Created" and "Updated" is useless…