Skip to content
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

Merged
merged 1 commit into from
May 20, 2019
Merged

✨ webhook: Handle TLS certificate rotation #421

merged 1 commit into from
May 20, 2019

Conversation

bison
Copy link
Contributor

@bison bison commented May 13, 2019

This watches the configured TLS certificate and key files for admission webhooks. On any change, it attempts to reload them from disk.

Fixes: #390

@k8s-ci-robot
Copy link
Contributor

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.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label May 13, 2019
@k8s-ci-robot k8s-ci-robot requested review from droot and pwittrock May 13, 2019 12:52
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 13, 2019
@mengqiy
Copy link
Member

mengqiy commented May 17, 2019

/assign

return nil
}

func (cw *CertWatcher) handleEvent(event fsnotify.Event) {
Copy link
Member

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.

Copy link
Contributor Author

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.

@mengqiy
Copy link
Member

mengqiy commented May 17, 2019

@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.
@bison
Copy link
Contributor Author

bison commented May 20, 2019

@mengqiy, thanks for having a look! I rebased and the tests seem to be passing now.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 20, 2019
Copy link
Member

@mengqiy mengqiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@mengqiy mengqiy added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 20, 2019
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Webhook server should reload certs on change
3 participants