Reloader icon indicating copy to clipboard operation
Reloader copied to clipboard

reload-on-create trigger rollingupdate of all deployments if Reloader pod restart

Open llavaud opened this issue 2 years ago • 5 comments

If I start Reloader with the "--reload-on-create=true" argument, everytime reloader pod is restarted it triggers a rolling update of all deployment that are "managed" by Reloader.

Example of Reloader logs after a restart:

time="2022-03-25T14:24:19Z" level=info msg="Environment: Kubernetes"
time="2022-03-25T14:24:19Z" level=info msg="Starting Reloader"
time="2022-03-25T14:24:19Z" level=warning msg="KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces."
time="2022-03-25T14:24:19Z" level=info msg="Starting Controller to watch resource type: secrets"
time="2022-03-25T14:24:19Z" level=info msg="Starting Controller to watch resource type: configMaps"
time="2022-03-25T14:24:20Z" level=info msg="Changes detected in 'nginx' of type 'CONFIGMAP' in namespace 'default'"
time="2022-03-25T14:24:20Z" level=info msg="Updated 'nginx-auto' of type 'Deployment' in namespace 'default'"
time="2022-03-25T14:24:20Z" level=info msg="Changes detected in 'nginx' of type 'CONFIGMAP' in namespace 'default'"
time="2022-03-25T14:24:20Z" level=info msg="Updated 'nginx-search' of type 'Deployment' in namespace 'default'"

I don't think it is an expected behaviour.

llavaud avatar Mar 25 '22 15:03 llavaud

This is a known issue, this tool has been designed to reload based on any change. The ability to reload based on new resource (secret/configmap) addition is optional and limited. The Kubernetes API return all the resources as new resources at the start and there isn't a way to check which resource was created with different content. So that's why the issue happens. We welcome any suggestions and also accept the contributions via PRs in case you have ideas for how to fix this :)

faizanahmad055 avatar Jun 18 '22 20:06 faizanahmad055

It is not possible to trigger rolling update on create/update events that occurs only after the Reloader's pod has started ?

llavaud avatar Jun 20 '22 12:06 llavaud

We welcome any suggestions and also accept the contributions via PRs in case you have ideas for how to fix this :)

Assuming --reload-strategy=annotations, shouldn't it be possible to compare the new hash against the hash in the reloader.stakater.com/last-reloaded-from annotation, and only trigger a rolling update if they differ?

klausenbusk avatar Dec 08 '22 13:12 klausenbusk

@faizanahmad055 is it still the case or could you please tell me any plan to implement this in new releases ?

mukesh-mohanan-db avatar May 02 '23 16:05 mukesh-mohanan-db

This should be fixed now. When reloader restarts it no longer automatically restarts the pods it is watching.

faizanahmad055 avatar May 02 '23 16:05 faizanahmad055