Skip to content

Commit a4dc01d

Browse files
authored
Merge pull request kubernetes#1712 from vivekbagade/master
Manifest based webhook configuration
2 parents 3ac6645 + fd78fd8 commit a4dc01d

File tree

2 files changed

+400
-0
lines changed

2 files changed

+400
-0
lines changed
Lines changed: 382 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,382 @@
1+
# Manifest based registration of Admission webhooks
2+
3+
## Table of Contents
4+
5+
<!-- toc -->
6+
- [Release Signoff Checklist](#release-signoff-checklist)
7+
- [Summary](#summary)
8+
- [Motivation](#motivation)
9+
- [Goals](#goals)
10+
- [Proposal](#proposal)
11+
- [Naming](#naming)
12+
- [Metrics and audit annotations](#metrics-and-audit-annotations)
13+
- [New AdmissionConfig schema](#new-admissionconfig-schema)
14+
- [Reconfiguring manifest file](#reconfiguring-manifest-file)
15+
- [Design Details](#design-details)
16+
- [Test Plan](#test-plan)
17+
- [Graduation Criteria](#graduation-criteria)
18+
- [Alpha -&gt; Beta Graduation](#alpha---beta-graduation)
19+
- [Beta -&gt; GA Graduation](#beta---ga-graduation)
20+
- [Removing a deprecated flag](#removing-a-deprecated-flag)
21+
- [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy)
22+
- [Version Skew Strategy](#version-skew-strategy)
23+
- [Production Readiness Review Questionnaire](#production-readiness-review-questionnaire)
24+
- [Feature enablement and rollback](#feature-enablement-and-rollback)
25+
- [Rollout, Upgrade and Rollback Planning](#rollout-upgrade-and-rollback-planning)
26+
- [Monitoring Requirements](#monitoring-requirements)
27+
- [Dependencies](#dependencies)
28+
- [Scalability](#scalability)
29+
- [Troubleshooting](#troubleshooting)
30+
- [Implementation History](#implementation-history)
31+
- [Drawbacks](#drawbacks)
32+
- [Alternatives](#alternatives)
33+
<!-- /toc -->
34+
35+
## Release Signoff Checklist
36+
37+
**ACTION REQUIRED:** In order to merge code into a release, there must be an issue in [kubernetes/enhancements] referencing this KEP and targeting a release milestone **before [Enhancement Freeze](https://github.com/kubernetes/sig-release/tree/master/releases)
38+
of the targeted release**.
39+
40+
For enhancements that make changes to code or processes/procedures in core Kubernetes i.e., [kubernetes/kubernetes], we require the following Release Signoff checklist to be completed.
41+
42+
Check these off as they are completed for the Release Team to track. These checklist items _must_ be updated for the enhancement to be released.
43+
44+
- [ ] kubernetes/enhancements issue in release milestone, which links to KEP (this should be a link to the KEP location in kubernetes/enhancements, not the initial KEP PR)
45+
- [ ] KEP approvers have set the KEP status to `implementable`
46+
- [ ] Design details are appropriately documented
47+
- [ ] Test plan is in place, giving consideration to SIG Architecture and SIG Testing input
48+
- [ ] Graduation criteria is in place
49+
- [ ] "Implementation History" section is up-to-date for milestone
50+
- [ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io]
51+
- [ ] Supporting documentation e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes
52+
53+
**Note:** Any PRs to move a KEP to `implementable` or significant changes once it is marked `implementable` should be approved by each of the KEP approvers. If any of those approvers is no longer appropriate than changes to that list should be approved by the remaining approvers and/or the owning SIG (or SIG-arch for cross cutting KEPs).
54+
55+
**Note:** This checklist is iterative and should be reviewed and updated every time this enhancement is being considered for a milestone.
56+
57+
[kubernetes.io]: https://kubernetes.io/
58+
[kubernetes/enhancements]: https://github.com/kubernetes/enhancements/issues
59+
[kubernetes/kubernetes]: https://github.com/kubernetes/kubernetes
60+
[kubernetes/website]: https://github.com/kubernetes/website
61+
62+
## Summary
63+
64+
Manifest based webhook configuration allows registering admission webhooks
65+
during kube-apiserver start up allowing for no delays in policy enforcement
66+
between policy addition and kube-apiserver startup.
67+
68+
## Motivation
69+
70+
Today most policy enforcement is implemented through MutatingAdmissionWebhooks
71+
and/or ValidatingAdmissionWebhooks. These admission webhooks are registered
72+
through creating MutatingWebhookConfiguration or ValidatingWebhookConfiguration
73+
objects. Any policy enforcement is not in place until these webhook
74+
configurations are created, thereby registering the webhook. This creates a gap
75+
in enforcement spanning from when the kube-apiserver is started to until the
76+
webhook configuration objects are created and picked up by the dynamic admission
77+
controller. Another gap is the inability of the cluster administrator to protect
78+
against deletion of these webhook configuration objects as
79+
MutatingWebhookConfiguration and ValidatingWebhookConfiguration objects are not
80+
subject to webhook admission policy.
81+
82+
This KEP aims to address these issues.
83+
84+
### Goals
85+
86+
- A robust admission webhook registration process where there is no period of
87+
time between the kube-apiserver coming up and the registration of an admission
88+
webhook.
89+
90+
- The registration of webhooks registered through this process should be
91+
protected from alteration by API requests made by cluster users.
92+
93+
- It should be possible to alter webhooks registered through this new process
94+
without restarting the kube-apiserver.
95+
96+
## Proposal
97+
98+
In short, this proposal is about augmenting `AdmissionConfig`'s plugin
99+
`configuration` [specification](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#authenticate-apiservers)
100+
to include a path to a configuration file containing one of the following:
101+
- `admissionregistration.k8s.io/v1.ValidatingWebhookConfigurationList`
102+
- `admissionregistration.k8s.io/v1.MutatingWebhookConfigurationList`
103+
- v1.List with items of admissionregistration.k8s.io/v1.ValidatingWebhookConfiguration
104+
- v1.List with items of admissionregistration.k8s.io/v1.MutatingWebhookConfiguration.
105+
This configuration is loaded as manifest based webhooks in api servers. These
106+
webhooks are called by validating and mutating admission plugins along with
107+
dynamically loaded webhooks for relevant admission requests. This also means
108+
that these webhooks are not API visible objects and hence cannot be modified by
109+
an API user.
110+
111+
### Naming
112+
All webhooks in the manifest file need to have unique names. If a new webhook
113+
configuration API object with a same name as a webhook in the manifest is added,
114+
both webhook would be invoked. Essentially, webhooks in the manifest file will
115+
be treated as belonging to a different domain from the webhooks registered
116+
through the API.
117+
118+
### Metrics and audit annotations
119+
Metrics and audit annotations for webhooks registered through the manifest file
120+
will be surfaced differently. This allows the administrator to unique monitor
121+
activity of these webhooks as they would be the only party able to take action
122+
against issues with these webhooks.
123+
124+
All admission metrics for webhooks will have an additional label `manifest_based`
125+
with a value `true` for webhooks registered via manifest.
126+
127+
Audit annotations for mutation webhooks will include another field `manifestBased`
128+
with a value `true` for webhooks registered via manifest.
129+
130+
```
131+
<<[UNRESOLVED sig-instrumentation ]>>
132+
get feedback on how to indicate this in metrics
133+
<<[/UNRESOLVED]>>
134+
```
135+
136+
### New AdmissionConfig schema
137+
138+
A `webhooksFile` field is added to `configuration` field of a plugin object in
139+
`AdmissionConfig`.
140+
141+
```yaml
142+
apiVersion: apiserver.config.k8s.io/v1
143+
kind: AdmissionConfiguration
144+
plugins:
145+
- name: ValidatingAdmissionWebhook
146+
configuration:
147+
....
148+
webhooksFile: "<path-to-manifest-file>"
149+
- name: MutatingAdmissionWebhook
150+
configuration:
151+
....
152+
webhooksFile: "<path-to-manifest-file>"
153+
```
154+
155+
### Reconfiguring manifest file
156+
157+
The manifest file is watched so that the webhook configuration can be
158+
dynamically changed by editing the contents of the file.
159+
160+
```
161+
<<[UNRESOLVED]>>
162+
need to define behavior in the following cases:
163+
1. file goes missing
164+
2. file cannot be read
165+
3. parse error reading file contents
166+
4. some webhook configurations listed in the file do not pass validation
167+
<<[/UNRESOLVED]>>
168+
```
169+
170+
## Design Details
171+
172+
### Test Plan
173+
174+
### Graduation Criteria
175+
176+
#### Alpha -> Beta Graduation
177+
178+
#### Beta -> GA Graduation
179+
180+
#### Removing a deprecated flag
181+
182+
### Upgrade / Downgrade Strategy
183+
184+
### Version Skew Strategy
185+
186+
## Production Readiness Review Questionnaire
187+
188+
### Feature enablement and rollback
189+
190+
* **How can this feature be enabled / disabled in a live cluster?**
191+
- [ ] Feature gate (also fill in values in `kep.yaml`)
192+
- Feature gate name:
193+
- Components depending on the feature gate:
194+
- [ ] Other
195+
- Describe the mechanism:
196+
- Will enabling / disabling the feature require downtime of the control
197+
plane?
198+
- Will enabling / disabling the feature require downtime or reprovisioning
199+
of a node? (Do not assume `Dynamic Kubelet Config` feature is enabled).
200+
201+
* **Does enabling the feature change any default behavior?**
202+
Any change of default behavior may be surprising to users or break existing
203+
automations, so be extremely careful here.
204+
205+
* **Can the feature be disabled once it has been enabled (i.e. can we roll back
206+
the enablement)?**
207+
Also set `disable-supported` to `true` or `false` in `kep.yaml`.
208+
Describe the consequences on existing workloads (e.g., if this is a runtime
209+
feature, can it break the existing applications?).
210+
211+
* **What happens if we reenable the feature if it was previously rolled back?**
212+
213+
* **Are there any tests for feature enablement/disablement?**
214+
The e2e framework does not currently support enabling or disabling feature
215+
gates. However, unit tests in each component dealing with managing data, created
216+
with and without the feature, are necessary. At the very least, think about
217+
conversion tests if API types are being modified.
218+
219+
### Rollout, Upgrade and Rollback Planning
220+
221+
_This section must be completed when targeting beta graduation to a release._
222+
223+
* **How can a rollout fail? Can it impact already running workloads?**
224+
Try to be as paranoid as possible - e.g., what if some components will restart
225+
mid-rollout?
226+
227+
* **What specific metrics should inform a rollback?**
228+
229+
* **Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?**
230+
Describe manual testing that was done and the outcomes.
231+
Longer term, we may want to require automated upgrade/rollback tests, but we
232+
are missing a bunch of machinery and tooling and can't do that now.
233+
234+
* **Is the rollout accompanied by any deprecations and/or removals of features, APIs,
235+
fields of API types, flags, etc.?**
236+
Even if applying deprecation policies, they may still surprise some users.
237+
238+
### Monitoring Requirements
239+
240+
_This section must be completed when targeting beta graduation to a release._
241+
242+
* **How can an operator determine if the feature is in use by workloads?**
243+
Ideally, this should be a metric. Operations against the Kubernetes API (e.g.,
244+
checking if there are objects with field X set) may be a last resort. Avoid
245+
logs or events for this purpose.
246+
247+
* **What are the SLIs (Service Level Indicators) an operator can use to determine
248+
the health of the service?**
249+
- [ ] Metrics
250+
- Metric name:
251+
- [Optional] Aggregation method:
252+
- Components exposing the metric:
253+
- [ ] Other (treat as last resort)
254+
- Details:
255+
256+
* **What are the reasonable SLOs (Service Level Objectives) for the above SLIs?**
257+
At a high level, this usually will be in the form of "high percentile of SLI
258+
per day <= X". It's impossible to provide comprehensive guidance, but at the very
259+
high level (needs more precise definitions) those may be things like:
260+
- per-day percentage of API calls finishing with 5XX errors <= 1%
261+
- 99% percentile over day of absolute value from (job creation time minus expected
262+
job creation time) for cron job <= 10%
263+
- 99,9% of /health requests per day finish with 200 code
264+
265+
* **Are there any missing metrics that would be useful to have to improve observability
266+
of this feature?**
267+
Describe the metrics themselves and the reasons why they weren't added (e.g., cost,
268+
implementation difficulties, etc.).
269+
270+
### Dependencies
271+
272+
_This section must be completed when targeting beta graduation to a release._
273+
274+
* **Does this feature depend on any specific services running in the cluster?**
275+
Think about both cluster-level services (e.g. metrics-server) as well
276+
as node-level agents (e.g. specific version of CRI). Focus on external or
277+
optional services that are needed. For example, if this feature depends on
278+
a cloud provider API, or upon an external software-defined storage or network
279+
control plane.
280+
281+
For each of these, fill in the following—thinking about running existing user workloads
282+
and creating new ones, as well as about cluster-level services (e.g. DNS):
283+
- [Dependency name]
284+
- Usage description:
285+
- Impact of its outage on the feature:
286+
- Impact of its degraded performance or high-error rates on the feature:
287+
288+
289+
### Scalability
290+
291+
_For alpha, this section is encouraged: reviewers should consider these questions
292+
and attempt to answer them._
293+
294+
_For beta, this section is required: reviewers must answer these questions._
295+
296+
_For GA, this section is required: approvers should be able to confirm the
297+
previous answers based on experience in the field._
298+
299+
* **Will enabling / using this feature result in any new API calls?**
300+
Describe them, providing:
301+
- API call type (e.g. PATCH pods)
302+
- estimated throughput
303+
- originating component(s) (e.g. Kubelet, Feature-X-controller)
304+
focusing mostly on:
305+
- components listing and/or watching resources they didn't before
306+
- API calls that may be triggered by changes of some Kubernetes resources
307+
(e.g. update of object X triggers new updates of object Y)
308+
- periodic API calls to reconcile state (e.g. periodic fetching state,
309+
heartbeats, leader election, etc.)
310+
311+
* **Will enabling / using this feature result in introducing new API types?**
312+
Describe them, providing:
313+
- API type
314+
- Supported number of objects per cluster
315+
- Supported number of objects per namespace (for namespace-scoped objects)
316+
317+
* **Will enabling / using this feature result in any new calls to the cloud
318+
provider?**
319+
320+
* **Will enabling / using this feature result in increasing size or count of
321+
the existing API objects?**
322+
Describe them, providing:
323+
- API type(s):
324+
- Estimated increase in size: (e.g., new annotation of size 32B)
325+
- Estimated amount of new objects: (e.g., new Object X for every existing Pod)
326+
327+
* **Will enabling / using this feature result in increasing time taken by any
328+
operations covered by [existing SLIs/SLOs]?**
329+
Think about adding additional work or introducing new steps in between
330+
(e.g. need to do X to start a container), etc. Please describe the details.
331+
332+
* **Will enabling / using this feature result in non-negligible increase of
333+
resource usage (CPU, RAM, disk, IO, ...) in any components?**
334+
Things to keep in mind include: additional in-memory state, additional
335+
non-trivial computations, excessive access to disks (including increased log
336+
volume), significant amount of data sent and/or received over network, etc.
337+
This through this both in small and large cases, again with respect to the
338+
[supported limits].
339+
340+
### Troubleshooting
341+
342+
The Troubleshooting section currently serves the `Playbook` role. We may consider
343+
splitting it into a dedicated `Playbook` document (potentially with some monitoring
344+
details). For now, we leave it here.
345+
346+
_This section must be completed when targeting beta graduation to a release._
347+
348+
* **How does this feature react if the API server and/or etcd is unavailable?**
349+
350+
* **What are other known failure modes?**
351+
For each of them, fill in the following information by copying the below template:
352+
- [Failure mode brief description]
353+
- Detection: How can it be detected via metrics? Stated another way:
354+
how can an operator troubleshoot without logging into a master or worker node?
355+
- Mitigations: What can be done to stop the bleeding, especially for already
356+
running user workloads?
357+
- Diagnostics: What are the useful log messages and their required logging
358+
levels that could help debug the issue?
359+
Not required until feature graduated to beta.
360+
- Testing: Are there any tests for failure mode? If not, describe why.
361+
362+
* **What steps should be taken if SLOs are not being met to determine the problem?**
363+
364+
[supported limits]: https://git.k8s.io/community//sig-scalability/configs-and-limits/thresholds.md
365+
[existing SLIs/SLOs]: https://git.k8s.io/community/sig-scalability/slos/slos.md#kubernetes-slisslos
366+
367+
## Implementation History
368+
369+
- 2020-04-21: KEP introduced
370+
371+
## Drawbacks
372+
373+
- Reduced visibility for users wanting to list all active admission webhooks.
374+
This KEP has similar visibility characteristics as compiled in admission
375+
controllers.
376+
377+
## Alternatives
378+
379+
Adding Deny policies to RBAC allowing a cluster administrator to create roles
380+
that deny access to certain webhook configuration objects was considered. But,
381+
adding Deny policies to RBAC has far reaching consequences like
382+
redesigning/changing the implementation of object watchers.

0 commit comments

Comments
 (0)