Skip to content

Add initializer support to admission and uninitialized filtering to rest storage #36721

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

Merged
merged 5 commits into from
Jun 3, 2017

Conversation

smarterclayton
Copy link
Contributor

@smarterclayton smarterclayton commented Nov 13, 2016

Initializers are the opposite of finalizers - they allow API clients to react to object creation and populate fields prior to other clients seeing them.

High level description:

  1. Add metadata.initializers field to all objects
  2. By default, filter objects with > 0 initializers from LIST and WATCH to preserve legacy client behavior (known as partially-initialized objects)
  3. Add an admission controller that populates .initializer values per type, and denies mutation of initializers except by certain privilege levels (you must have the initialize verb on a resource)
  4. Allow partially-initialized objects to be viewed via LIST and WATCH for initializer types
  5. When creating objects, the object is "held" by the server until the initializers list is empty
  6. Allow some creators to bypass initialization (set initializers to []), or to have the result returned immediately when the object is created.

The code here should be backwards compatible for all clients because they do not see partially initialized objects unless they GET the resource directly. The watch cache makes checking for partially initialized objects cheap. Some reflectors may need to change to ask for partially-initialized objects.

Kubernetes resources, when the `Initializers` admission controller is enabled, can be initialized (defaulting or other additive functions) by other agents in the system prior to those resources being visible to other clients.  An initialized resource is not visible to clients unless they request (for get, list, or watch) to see uninitialized resources with the `?includeUninitialized=true` query parameter.  Once the initializers have completed the resource is then visible.  Clients must have the the ability to perform the `initialize` action on a resource in order to modify it prior to initialization being completed.

@smarterclayton smarterclayton added this to the v1.6 milestone Nov 13, 2016
@smarterclayton smarterclayton added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Nov 13, 2016
@smarterclayton
Copy link
Contributor Author

smarterclayton commented Nov 13, 2016

@liggitt @bgrant0607 @derekwaynecarr @ncdc @kubernetes/sig-api-machinery as discussed at KubeCon there was a general feeling that initializers are technically solvable and a better path than more complexity in admission extension (make admission extensible like controllers is a better story than more web hooks, each of which is a net new API). I think from prototyping it that this will be no worse for performance than any out of process admission controller, and because it can leverage informers it's actually the most performant approach.

This does not obviate cleaning up admission control in process - the most efficient way to have admission would still be one big chain, as opposed to many small ones. But I think it solves the fifth part of #34131 better than the other approaches.

@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note-label-needed labels Nov 13, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GKE smoke e2e failed for commit 2444005. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins GKE smoke e2e failed for commit 2444005. Full PR test history.

The magic incantation to run this job again is @k8s-bot cvm gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@bgrant0607
Copy link
Member

(5) means that apiserver doesn't respond to the creation request until initialization has completed or failed, correct?

@bgrant0607
Copy link
Member

#17305

@smarterclayton
Copy link
Contributor Author

Or timeout, correct. Will be trying to draft a larger proposal soon to cover the full scope of extension (on top of ncdc's previous work).

}

func (i initializer) Handles(op admission.Operation) bool {
return op == admission.Create
Copy link
Member

Choose a reason for hiding this comment

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

I thought we still have some objects that support create on update?

@derekwaynecarr
Copy link
Member

I like where this is going. Let me know if I can help in any particular area.

@deads2k
Copy link
Contributor

deads2k commented Nov 23, 2016

I like where this is going. Let me know if I can help in any particular area.

Funny you should ask. :) Quota of non-count resources needs to be refactored to be an initializer so that it can run after all initializers have had a chance to update those resources. The admission path for "update things that haven't been initialized" is different than a normal "update" and could easily end up more noisy than it needs to be with multiple writes happening before the end of initialization which would require excessive compensation (openshift normally goes through two passes right?).

Also, refactoring resource quota as initialization makes it possible to provide an easy entry point for any API server to ask for quota on an immutable field (or an expensive count implementation) without needing to compile in and configure an implementation of quota in its admission chain. Combine it with a way find resource-y things (same problem as our current podspec-y things) and it ought to just work.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 24, 2016
@smarterclayton
Copy link
Contributor Author

Started a proposal at kubernetes/community#132

@smarterclayton
Copy link
Contributor Author

smarterclayton commented Jan 1, 2017 via email

@deads2k
Copy link
Contributor

deads2k commented Jan 9, 2017

Quota would not be an initializer - it doesn't need to be extensible in the
vast majority of cases (each api server only manages quota for its own
resources).

You have to calculate quota after all limits have been set. That can't be done in the admission chain since an initializer can change it. Where would it happen?

@smarterclayton
Copy link
Contributor Author

smarterclayton commented Jan 9, 2017 via email

@smarterclayton smarterclayton removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 2, 2017
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 2, 2017
@smarterclayton smarterclayton added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 2, 2017
@smarterclayton
Copy link
Contributor Author

Trivial rebase

@smarterclayton
Copy link
Contributor Author

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@smarterclayton
Copy link
Contributor Author

@smarterclayton
Copy link
Contributor Author

@k8s-bot pull-kubernetes-unit test this

@smarterclayton
Copy link
Contributor Author

@k8s-bot pull-kubernetes-unit test this
@k8s-bot pull-kubernetes-e2e-kops-aws test this

@smarterclayton
Copy link
Contributor Author

@k8s-bot pull-kubernetes-verify test this

Add support for creating resources that are not immediately visible to
naive clients, but must first be initialized by one or more privileged
cluster agents. These controllers can mark the object as initialized,
allowing others to see them.

Permission to override initialization defaults or modify an initializing
object is limited per resource to a virtual subresource "RESOURCE/initialize"
via RBAC.

Initialization is currently alpha.
Running without an authorizer is a valid configuration.
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 3, 2017
@smarterclayton
Copy link
Contributor Author

@k8s-bot pull-kubernetes-verify test this

@smarterclayton
Copy link
Contributor Author

/lgtm
rebase fixup

@k8s-ci-robot
Copy link
Contributor

@smarterclayton: you cannot LGTM your own PR.

In response to this:

/lgtm
rebase fixup

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.

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

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

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@smarterclayton smarterclayton added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 3, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 07f8556 into kubernetes:master Jun 3, 2017
@lavalamp
Copy link
Member

lavalamp commented Jun 5, 2017

yay, it merged. Time for me to rebase :)

k8s-github-robot pushed a commit that referenced this pull request Jun 6, 2017
Automatic merge from submit-queue (batch tested with PRs 46967, 46992, 43338, 46717, 46672)

Select initializers from the dynamic configuration

Continues #36721

kubernetes/enhancements#209
vdemeester pushed a commit to vdemeester/kubernetes that referenced this pull request Jun 8, 2017
…before-1.7

Automatic merge from submit-queue

Remove Initializers from admission-control in kubernetes-master charm for pre-1.7

**What this PR does / why we need it**:

This fixes a problem with the kubernetes-master charm where kube-apiserver never comes up:

```
failed to initialize admission: Unknown admission plugin: Initializers
```

The Initializers plugin does not exist before Kubernetes 1.7. The charm needs to support 1.6 as well.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes kubernetes#47062

**Special notes for your reviewer**:

This fixes a problem introduced by kubernetes#36721

**Release note**:

```release-note
Remove Initializers from admission-control in kubernetes-master charm for pre-1.7
```
tvansteenburgh pushed a commit to charmed-kubernetes/charm-kubernetes-control-plane that referenced this pull request Apr 1, 2019
Automatic merge from submit-queue

Remove Initializers from admission-control in kubernetes-master charm for pre-1.7

**What this PR does / why we need it**:

This fixes a problem with the kubernetes-master charm where kube-apiserver never comes up:

```
failed to initialize admission: Unknown admission plugin: Initializers
```

The Initializers plugin does not exist before Kubernetes 1.7. The charm needs to support 1.6 as well.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #47062

**Special notes for your reviewer**:

This fixes a problem introduced by kubernetes/kubernetes#36721

**Release note**:

```release-note
Remove Initializers from admission-control in kubernetes-master charm for pre-1.7
```
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. 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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.