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

Allow Mutating|ValidatingWebhookConfiguration to use secret for CABundle #72944

Open
mengqiy opened this issue Jan 15, 2019 · 23 comments
Open

Allow Mutating|ValidatingWebhookConfiguration to use secret for CABundle #72944

mengqiy opened this issue Jan 15, 2019 · 23 comments
Assignees
Labels
area/admission-control kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.

Comments

@mengqiy
Copy link
Member

mengqiy commented Jan 15, 2019

What would you like to be added:
Allow Mutating|ValidatingWebhookConfiguration to reference content of a secret as CABundle.

The following shows the idea. We can use better names than below.

type WebhookClientConfig struct {
	URL *string `json:"url,omitempty" protobuf:"bytes,3,opt,name=url"`
	Service *ServiceReference `json:"service,omitempty" protobuf:"bytes,1,opt,name=service"`
	CABundle []byte `json:"caBundle,omitempty" protobuf:"bytes,2,opt,name=caBundle"`

	// Optional field that reference a secret.
	CAFromSecret *CASecret
}

type CASecret struct {
	// the namespace of the secret
	Namespace string
	// the name of the secret
	Name string
	// the key in the secret. e.g. ca.key
	KeyName string
}

This can also be applied to CRD conversion webhook

Why is this needed:
It will be very useful if the CA is rotated.
Before: An admin or a controller (with permission to update WebhookConfiguration) need to update CABundle field if the CA has changed.
After: The Webhook configuration will automatically pickup the new CA.

EDIT:
From the security PoV, another advantage is that no need to update the CA means we don't need to grant permissions to some controller for Updating the CABundle field in Mutating|ValidatingWebhookConfig. Current k8s authn doesn't support field-wise fine-grain access control. IOW, a compromised controller can modify the service field of MutatingWebhookConfig to point a random service that may inject an arbitrary container to each pod.

@mengqiy mengqiy added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 15, 2019
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jan 15, 2019
@mengqiy
Copy link
Member Author

mengqiy commented Jan 15, 2019

/sig api-machinery

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 15, 2019
@mengqiy
Copy link
Member Author

mengqiy commented Jan 15, 2019

cc: @liggitt @caesarxuchao

@yue9944882
Copy link
Member

yue9944882 commented Jan 16, 2019

isn't configmap a better place to store CA? @deads2k

ref openshift ca rotation: openshift/cluster-kube-apiserver-operator#164

@krmayankk
Copy link

putting the caBundle inline in the configuration yaml makes it unreadable
caBundle: <pem encoded ca cert that signs the server cert used by the webhook> . it would be much better to read it from a configmaps

@fedebongio
Copy link
Contributor

/assign @caesarxuchao

@caesarxuchao
Copy link
Member

cc @mbohlool @deads2k

@mbohlool
Copy link
Contributor

I think it is a good idea. Ad if we want to do it, it has API implications that I prefer it to be included in v1 API for Admission Webhook GA. @sttts @deads2k @caesarxuchao what do you think?

@liggitt
Copy link
Member

liggitt commented Jan 25, 2019

I'm on the fence about whether this is desirable or not.

Things I see as pros:

  • Update of a CA key in a configmap or secret is way more scoped than giving webhook update permission
  • Cert management integrations for kube are more likely to support targeting a configmap or secret
  • A CA bundle is more readable in a dedicated configmap
  • Pointing several webhook configs at a single configmap/secret object allows for easier rotation

Things I see as cons:

  • denormalizing means joining watches from two resource types to control the configured admission plugins
  • it means webhook config is no longer self-contained
  • granting read permission to the secret/configmap to all the subjects that will be setting up webhook admission calls is not straightforward in the case of extension API servers... the subjects used by extension apiservers to look up the referenced objects are not knowable in advance as the webhook config author, and the secrets/configmaps containing CAs are not knowable in advance as the extension API server deployer.
  • introduces additional failure modes (referenced object doesn't exist, cannot be read, etc)

@deads2k
Copy link
Contributor

deads2k commented Jan 28, 2019

isn't configmap a better place to store CA? @deads2k

ref openshift ca rotation: openshift/cluster-kube-apiserver-operator#164

When rotating a bundle that is going to be mounted into a pod, it makes a lot of sense to coordinate in configmaps. However, here we're talking about trying to manage a resource that is designed to be watched live for reaction and never mounted. While it is possible to do this with a configmap, you end up having to write an effective join between the two.

In a case where you're reading live object data, I think it's easier to take an approach similar to how the openshift/service-ca injects cabundles into annotated apiservices. The update can take place directly in the resource you're already watching.

@Benjamintf1
Copy link
Contributor

When referencing certificates in the context of a service, a secret is used. Why should this be any different?

@liggitt liggitt added priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. area/admission-control labels Jun 12, 2019
@liggitt liggitt added this to Not required for GA in Admission Webhooks Jun 12, 2019
@liggitt liggitt moved this from Bugs/Cleanup/Tests to Proposed enhancements in Admission Webhooks Aug 30, 2019
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 10, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 10, 2019
@krmayankk
Copy link

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Oct 10, 2019
@mgoltzsche
Copy link
Contributor

mgoltzsche commented Oct 10, 2019

FYI: cert-manager's cainjector solves this by injecting a Certificate into the caBundle field of APIServices or Mutating/ValidatingWebhooks annotated with certmanager.k8s.io/inject-ca-from: <NAMESPACE>/<CERTIFICATE>.

UPDATE: With cert-manager 0.11 it changed to:
cert-manager.io/inject-ca-from: <NAMESPACE>/<CERTIFICATE>

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 9, 2020
@pierluigilenoci
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 10, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 9, 2020
@grosser
Copy link

grosser commented Apr 9, 2020

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 9, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 8, 2020
@grosser
Copy link

grosser commented Jul 8, 2020

/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 8, 2020
@grosser
Copy link

grosser commented Jul 8, 2020

@liggitt can priority/awaiting-more-evidence be removed ... to me there seems to be no evidence missing ?

@dobesv
Copy link
Contributor

dobesv commented Sep 18, 2020

You can workaround this by installing cert-manager's cainjector and setting the appropriate annotation, it will set the caBundle for you from a TLS secret.

@mikhailadvani
Copy link

doesn't the configmapRef become more relevant post the 1.20 release of RootCAConfigMap https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.20.md#introducing-rootcaconfigmap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/admission-control kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
Admission Webhooks
Proposed enhancements
Development

No branches or pull requests