diff --git a/sig-api-machinery/design-docs/admission-control-webhooks.md b/sig-api-machinery/design-docs/admission-control-webhooks.md new file mode 100644 index 000000000..551754fe9 --- /dev/null +++ b/sig-api-machinery/design-docs/admission-control-webhooks.md @@ -0,0 +1,908 @@ +# Webhooks Beta + + +## PUBLIC +Authors: @erictune, @caesarxuchao, @enisoc +Thanks to: {@dbsmith, @smarterclayton, @deads2k, @cheftaco, @jpbetz, @mbohlool, @mml, @janetkuo} for comments, data, prior designs, etc. + + +[TOC] + + +**Discussion and Decision for this Beta plan desired at 11 October SIG-API-Machinery meeting, due to short release cycle in 1.9.** + + +# Summary + +This document proposes a detailed plan for bringing Webhooks to Beta. Highlights include (incomplete, see rest of doc for complete list) : + + + +* Adding the ability for webhooks to mutate. +* Bootstrapping +* Monitoring +* Versioned rather than Internal data sent on hook +* Ordering behavior within webhooks, and with other admission phases, is better defined + +This plan is compatible with the [original design doc]( https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/admission_control_extension.md). + + +# Definitions + +**Mutating Webhook**: Webhook that can change a request as well as accept/reject. + +**Non-Mutating Webhook**: Webhook that cannot change request, but can accept or reject. + +**Webhook**: encompasses both Mutating Webhook and/or Non-mutating Webhook. + +**Validating Webhook**: synonym for Non-Mutating Webhook + +**Static Admission Controller**: Compiled-in Admission Controllers, (in plugin/pkg/admission). + + +# Development Plan + +Google able to staff development, test, review, and documentation. Community help welcome, too, esp. Reviewing. + +Intent is Beta of Webhooks (**both** kinds) in 1.9. + +Not in scope: + + + +* Initializers remains Alpha for 1.9. (See [Comparison of Webhooks and Initializers](#comparison-of-webhooks-and-initializers) section). No changes to it. Will revisit its status post-1.9. +* Converting static admission controllers is out of scope (but some investigation has been done, see Moving Built-in Admission Controllers section). +* Internal Go interface refactor (e.g. along the lines suggested #[1137](https://github.com/kubernetes/community/pull/1137)). Nice-to-have but not gating beta. + + +## Work Items + + + +* Add API for registering mutating webhooks. See + +
>>>> GDC alert: undefined internal link (link text: "API Changes"). Did you generate a TOC?
(Back to top)(Next alert)
>>>>
>>>> GDC alert: undefined internal link (link text: "Responses for Mutations"). Did you generate a TOC?
(Back to top)(Next alert)
>>>>
Admission Controller + | +How + | +Why + | +
PodSecurityPolicy + | +Use Mutating Webhook and Non-Mutating Webhook. + | +Requires User.Info, so needs webhook.
+ +Mutating will set SC from matching PSP. + +Non-Mutating will check again in case any other mutators or initializers try to change it. + |
+
ResourceQuota + | +Leave static + | +A Redesign for Resource Quota has been proposed, to allow at least object count quota for other objects as well. This suggests that Quota might need to remain compiled in like authn and authz are. + | +
AlwaysPullImages + | +Use Mutating Webhook (could implement using initializer since the thing is it validating is forbidden to change by Update Validation of the object) + | +Needs to + | +
AntiAffinity + | +Move to pod validation + | +Since this is provided by the core project, which also manages the pod business logic, it isn't clear why this is even an admission controller. Ask Scheduler people. + | +
DefaultTolerationSeconds + | +Move to pod defaulting or use a Mutating Webhook. + | +It is very simple. + | +
eventratelimit + | +Non-mutating webhook + | +Simple logic, does not mutate. Alternatively, have rate limit be a built-in of api server. + | +
DenyEscalatingExec + | +Non-mutating Webhook. + | +It is very simple. It is optional. + | +
OwnerReferences- PermissionEnforcement (gc) + | +Leave compiled in + | +Garbage collection is core to Kubernetes. Main and all aggregated apiservers should enforce it. + | +
ImagePolicy + | +Non-mutating webhook + | +Must use webhook since image can be updated on pod, and that needs to be checked. + | +
LimitRanger + | +Mutating Webhook + | +Fast + | +
NamespaceExists + | +Leave compiled in + | +This has been on by default for years, right? + | +
NamespaceLifecycle + | +Split:
+ + + +Cleanup, leave compiled in. + + + +Protection of system namespaces: use non-mutating webhook + |
+ + | +
NodeRestriction + | +Use a non-mutating webhook + | +Needs webhook so it can use User.Info. + | +
PersistentVolumeClaimResize + | +Move to validation + | +This should be in the validation logic for storage class. + | +
PodNodeSelector + | +Move to non-mutating webhook + | +Already compiled in, so fast enough to use webhook. Does not mutate. + | +
podtolerationrestriction + | +Move to non-mutating webhook + | +Already compiled in, so fast enough to use webhook. Does not mutate. + | +
serviceaccount + | +Move to mutating webhook. + | +Already compiled in, so fast enough to use webhook. Does mutate by defaulting the service account. + | +
storageclass + | +Move to mutating webhook. + | ++ | +
Admission Controller + | +How + | +Why + | +
pkg/authorization/admission/restrictusers" + | +Non-mutating Webhook or leave static + | +Verification only. But uses a few loopback clients to check other resources. + | +
pkg/build/admission/jenkinsbootstrapper + | +Non-mutating Webhook or leave static + | +Doesn't mutate Build or BuildConfig, but creates Jenkins instances. + | +
pkg/build/admission/secretinjector + | +Mutating webhook or leave static + | +uses a few loopback clients to check other resources. + | +
pkg/build/admission/strategyrestrictions + | +Non-mutating Webhook or leave static + | +Verifications only. But uses a few loopback clients, and calls subjectAccessReview + | +
pkg/image/admission + | +Non-Mutating Webhook + | +Fast, checks image size + | +
pkg/image/admission/imagepolicy + | +Mutating and non-mutating webhooks + | +Rewriting image pull spec is mutating.
+ +acceptor.Accepts is non-Mutating + |
+
pkg/ingress/admission + | +Non-mutating webhook, or leave static. + | +Simple, but calls to authorizer. + | +
pkg/project/admission/lifecycle + | +Initializer or Non-mutating webhook? + | +Needs to update another resource: Namespace + | +
pkg/project/admission/nodeenv + | +Mutating webhook + | +Fast + | +
pkg/project/admission/requestlimit + | +Non-mutating webhook + | +Fast, verification only + | +
pkg/quota/admission/clusterresourceoverride + | +Mutating webhook + | +Updates container resource request and limit + | +
pkg/quota/admission/clusterresourcequota + | +Leave static. + | +Refactor with the k8s quota + | +
pkg/quota/admission/runonceduration + | +Mutating webhook + | +Fast. Needs a ProjectCache though. Updates pod.Spec.ActiveDeadlineSeconds + | +
pkg/scheduler/admission/podnodeconstraints + | +Non-mutating webhook or leave static + | +Verification only. But calls to authorizer. + | +
pkg/security/admission + | +Use Mutating Webhook and Non-Mutating Webhook. + | +Similar to PSP in k8s + | +
pkg/service/admission/externalip + | +Non-mutating webhook + | +Fast and verification only + | +
pkg/service/admission/endpoints + | +Non-mutating webhook or leave static + | +Verification only. But calls to authorizer. + | +
+Function + | +How + | +Why + | +
Istio Pod Injector + | +Mutating Webhook + | +Containers can only be added at pod creation time.
+ +Because the change is complex, showing intermediate state may help debugging. + +Fast, so could also use webhook. + |
+
Istio Mixer CRD Validation + | +Non-Mutating Webhook + | ++ | +
Service Catalog PodPreset + | +Initializer + | +Containers can only be added at pod creation time.
+ +Because the change is complex, showing intermediate state may help debugging. + +Fast, so could also use webhook. + |
+
Allocate Cert for Service + | +Initializer + | +Longer duration operation which might fail, with external dependency, so don't use webhook.
+ +Let user see initializing state. + +Don't let controllers that depend on services see the service before it is ready. + |
+
Mutating and Non-Mutating Webhooks + | +Initializers (and Finalizers) + | +
|
+
|
+
|
+
|
+
|
+
|
+
|
+
|
+
|
+
|
+
|
+
|
+
+ Use Examples:
|
+
+ Use Examples:
|
+