-
Notifications
You must be signed in to change notification settings - Fork 189
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
[WIP] *: watch tls certificate changes #45
Conversation
Testing on an openshift-cluster this looks fine. Noticeable is that those certs are chmod'ed every ~1minute:
I think we can ignore |
setting as WIP, as I am losing fsnotify events after |
Let me know when it's ready for review. It may very well be that the config watchers are not 100% correct today. Let's not worry about those right now, and just do it properly here :) |
@brancz this is ready for an initial pass. We have the following situation: Simply watching the cert/key paths won't work, because in k8s land an atomic configmap/secret swap is done using a double symlink approach:
k8s atomically swaps
Since golang's fsnotify library always evaluates symlinks as per https://github.com/fsnotify/fsnotify/blob/c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9/kqueue.go#L192 we only get a viper's approach linked above does
This is a sound approach, but tracking the symlink target evaluation implies state tracking which we can avoid by simply watching the intermediate symlink Whenever k8s updates the configmap, a The only problem is, that we cannot fsnotify on As a workaround, we watch for events in the whole directory (as viper does), and filter out events relating to This implementation also includes the possibility to track changes on the certificates directly in case they are simple files and not symlinks for brevity. |
case <-ctx.Done(): | ||
return nil | ||
|
||
case event := <-watcher.Events: |
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.
I wonder if we, in addition should add a ticker anyways. I am not sure we have 100% guarantees to catch all file system events, cc @lucab.
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.
Curious: for this very case, why not just read the files once per minute and apply if they changed? For other cases I agree that reloading as quickly as possible when available makes perfect sense, but here we have a lot of time to apply cert rotation anyways no?
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.
sounds good yes, this will simplify a lot of things and we don't have to think about edge cases 👍 let me implement a ticker-only based approach here and reuse the implemented logic here for prometheus-config-reloader.
Is this still WIP or can we close it? |
this is historic and can be closed |
Bug 1933599: bump k8s.io/apiserver to 1.20.4
TODOs:
/cc @brancz @metalmatze @paulfantom