-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: auto restart deployment when secret files change #43
Conversation
Just pushed a small commit to correct the Helm value comment for |
Hi @uvegla, you also need to increment the chart version |
Signed-off-by: Laszlo Uveges <[email protected]>
Fixed commit message and added sign off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Is this restart async, meaning it can interrupt a zot possibly in the middle of things (we do protect against this quite a bit though) |
AFAIR zot auto reloads config on the change using ionotify, and the helm chart does not use subpaths so you do not need to explicitly roll out restart on change, when secret changes then in about 1 minute k8s will update mounted secret. |
@nvtkaszpir I gave that a try, but I think it is not working, at least not for secrets. Here is what I did to test that. Relevant parts of my configuration: mountSecret: true
secretFiles:
privateRegistries: |-
{
"my-private-registry.example.org": {
"username": "test",
"password": "my-token"
}
}
configFiles:
config.json: |-
# ...
"log":
{
"level": "debug"
},
"extensions": {
"sync": {
"enable": true,
"credentialsFile": "/secret/privateRegistries",
"registries": [
{
"urls": [
"https://my-private-registry.example.org"
],
"onDemand": true,
"tlsVerify": true,
"maxRetries": 3,
"retryDelay": "5m"
}
]
},
}
#... In my test I also exposed it via an authenticated ingress - config for that I left our for simplicity -, lets say The Then this works: docker login -u test -p password my-cache.example.org
docker pull my-cache.example.org/my-org/my-image:v1 Then I invalidate the token for Even after minutes, this fails: docker pull my-cache.example.org/my-org/my-image:v2 Even tho runing with If I kill the pod, the new one will have it working just fine and the above pull works, so the updated credentials are used towards It is just a hunch, but I experienced previously in Kubernetes with other apps, that file system watchers are not working correctly with volume mounts. Not super sure it is related or similar (tho Also related, but they lead back to that above linked issue: |
OK so, this change is indeed good if some volume mounts do not support updates (especially subpaths are not supporting it). One more thing - zot generates a log message if the config is updated, worth to check in the logs if that happened. |
@nvtkaszpir Do you mean this: https://github.com/project-zot/zot/blob/v2.0.1/pkg/api/controller.go#L378-L379? I redid the above scenario, but I don't see that or anything resembling that the config was reloaded. So I assume it is not that it is reloaded just does not take effect for further upstream registry calls. However when I try to pull before the pod is manually restarted, logs state that Examples:
|
@uvegla I must say I did not try zot in container (yet), but directly running binary on the host with systemd picks up config changes as I described. |
also please sign your commit because it is required to accept the PR :) |
What type of PR is this?
feature
What does this PR do / Why do we need it:
This PR ensure when the
secretFiles
changes andmountSecret
is true, zot deployment will be automatically restarted.This will eliminate the manual zot restart step after secrets change.
This is done per helm's official best practice guide.
This is very similar to what #36 achieved just for secrets.
Additionally I fixed the comment for the
.configFiles
Helm value as the reload was fixed in the above PR.Testing done on this change:
Unit test added.
Automation added to e2e:
N/A
Will this break upgrades or downgrades?
No.
Does this PR introduce any user-facing change?:
Changing secret files will now automatically restart Zot's deployment.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.