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

Correct optional/omitempty indicator on webhook cabundle #70138

Merged
merged 3 commits into from Oct 23, 2018

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Oct 23, 2018

What type of PR is this?
/kind bug

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #69590

Does this PR introduce a user-facing change?:

The caBundle and service fields in admission webhook API objects now correctly indicate they are optional

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 23, 2018
@enj
Copy link
Member

enj commented Oct 23, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 23, 2018
@liggitt liggitt added this to the v1.13 milestone Oct 23, 2018
@liggitt
Copy link
Member Author

liggitt commented Oct 23, 2018

/assign @lavalamp @deads2k
for aggregator package approval

@lavalamp
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lavalamp, liggitt

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 23, 2018
@k8s-ci-robot k8s-ci-robot merged commit 1fe288e into kubernetes:master Oct 23, 2018
@tamalsaha
Copy link
Member

Thanks for fixing the bug @liggitt . Does this pass the bar for cherry picking in previous versions?

@liggitt liggitt deleted the optional-ca-bundle branch October 24, 2018 01:32
@liggitt
Copy link
Member Author

liggitt commented Oct 24, 2018

Does this pass the bar for cherry picking in previous versions?

I wouldn't think so, since the issue can be worked around by including this in your manifest:

caBundle: ""

@lavalamp
Copy link
Member

lavalamp commented Oct 24, 2018 via email

@ramnes
Copy link

ramnes commented Aug 21, 2019

@liggitt Do I understand correctly that with this PR merged in, an empty caBundle value should be equivalent to a caBundle that contains $(kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}') (as seen here)?

If so, how to explain that I end up with errors like x509: certificate signed by unknown authority without caBundle, whereas it works correctly when specified?

@liggitt
Copy link
Member Author

liggitt commented Aug 21, 2019

@liggitt Do I understand correctly that with this PR merged in, an empty caBundle value should be equivalent to a caBundle that contains $(kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}') (as seen here)?

no. an empty caBundle means the apiserver should use the system trust roots to verify the webhook's serving certificate.

@liggitt
Copy link
Member Author

liggitt commented Aug 21, 2019

From https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.15/#webhookclientconfig-v1beta1-admissionregistration-k8s-io:

caBundle is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used.

@ramnes
Copy link

ramnes commented Aug 21, 2019

Oh! You mean certificates in /etc/ssl/certs basically, right? Then would you consider it a good practice to add a cluster CA there?

@ramnes
Copy link

ramnes commented Aug 21, 2019

It seems pretty inconvenient to me that a webhook without caBundle can't be called even if it uses certificates that have been signed by the cluster's CSR mechanism itself.

@liggitt
Copy link
Member Author

liggitt commented Aug 21, 2019

Oh! You mean certificates in /etc/ssl/certs basically, right?

Yeah, or your platform's equivalent

Then would you consider it a good practice to add a cluster CA there?

It could, depending on your deployment. If an API server is running in an image and is the only thing in the image, injecting a cluster CA could make sense.

It seems pretty inconvenient to me that a webhook without caBundle can't be called even if it uses certificates that have been signed by the cluster's CSR mechanism itself.

The CSR API does not guarantee a single signer, and does not guarantee what audiences accept certs obtained via it. See #69836 for a list of items that need further clarification before graduating that API.

@ramnes
Copy link

ramnes commented Aug 21, 2019

Thanks a bunch for the quick answers, it's much more clear now.

One last question: would it make sense to modify the API server so that it internally check webhooks certificates against its own CA, on top of its system trusted roots?

@liggitt
Copy link
Member Author

liggitt commented Aug 21, 2019

would it make sense to modify the API server so that it internally check webhooks certificates against its own CA

the API server doesn't have a CA... controllers running outside the API server as clients sign the CSR API objects

the API server is given CA bundles for the following things:

  • verifying client certificates presented in requests to the API server (--client-ca-file)
  • verifying connections to an OIDC server for fetching discovery info (--oidc-ca-file)
  • verifying authenticating proxy client certificates presented in requests to the API server (--requestheader-client-ca-file)
  • verifying kubelet serving certificates (--kubelet-certificate-authority)

falling back to system roots for verification of webhook serving certificates is more reasonable than using any of those

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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CABundle should not be required in Webhook ClientConfig
7 participants