keel-hq / keel

Kubernetes Operator to automate Helm, DaemonSet, StatefulSet & Deployment updates
https://keel.sh
Mozilla Public License 2.0
2.45k stars 282 forks source link

Create new "digest" policy #326

Open burdiyan opened 5 years ago

burdiyan commented 5 years ago

I suggest creating a new update policy, that would only trigger the update if the digest of the image changed. I'll explain our use case.

We have a single repository with multiple applications. We build and release images for all these application on each commit. But in reality, in any given commit, only a subset of applications change. We tag all images with Git commit SHA. So, in one commit, all images are tagged, only some of them really changed, and those that didn't change aren't uploaded as, their digest is not changed.

Currently, Keel is triggering the update, even for images that didn't really change, but just were tagged with different commit SHA. It would be great if Keel could identify that in reality the image is the same, and update is not needed.

It would be great though, if Keel could annotate somehow the affected Resource with some annotation. But it should not touch pod template, so that update is not triggered.

rusenask commented 5 years ago

With the new pluggable policies it should be possible to add such policy, interface can be found here: https://github.com/keel-hq/keel/blob/master/internal/policy/policy.go#L21-L25, and GCR pubsub, dockerhub/gitlab/harbor/azure webhooks seem to be supporting digest as well (at least I see them in the example payloads). I guess the only problem would be knowing current image digest and just accessing this info inside the new policy. I would probably suggest implementing it in a separate package.


Keel currently does update the workloads so you can see rollout history:

➜  kubectl rollout history deployment/whr
deployments "whr"
REVISION  CHANGE-CAUSE
41        keel automated update version 0.10.5 -> 0.10.6