-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
✨ webhook: Handle TLS certificate rotation #421
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/assign |
return nil | ||
} | ||
|
||
func (cw *CertWatcher) handleEvent(event fsnotify.Event) { |
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.
When a secret get updated it actually triggers a rename event. Ref: algorithm of volume writer.
I'd like to know what testing has been done to verify if it work.
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.
Right, this is a bit tricky. So, fsnotify always fully resolves symlinks. In the case of a Kubernetes volume mount, the certificate and key files in the current data directory are watched. On an update, it's actually the remove event after the rename that is picked up here, then the watch is re-added following the new symlink.
I've tested this manually pretty extensively. My use-case is that I have another controller in the cluster generating and rotating short-lived TLS certificates for my controller-runtime based project. With this patch, webhook requests have continued to succeed after the periodic refresh of the TLS assets.
@bison Please fix travis build |
This watches the configured TLS certificate and key files for admission webhooks. On any change, it attempts to reload them from disk.
@mengqiy, thanks for having a look! I rebased and the tests seem to be passing now. |
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
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: bison The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This watches the configured TLS certificate and key files for admission webhooks. On any change, it attempts to reload them from disk.
Fixes: #390