-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Dynamic registration prototype #46294
Dynamic registration prototype #46294
Conversation
c7343ad
to
d2f74ae
Compare
4ce5527
to
5274cdb
Compare
*/ | ||
|
||
// This package is intended to be used by k8s.io/aiserver/pkg/registry/apiserver | ||
// only. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The registry needs Registry, Scheme, Codecs etc. Because we are in k8s.io/apiserver, we cannot import k8s.io/kubernetes/pkg/api, so i have to create this package.
install.Install(GroupFactoryRegistry, Registry, Scheme) | ||
// Register Unversioned types under their own special group | ||
|
||
unversioned := schema.GroupVersion{Group: "", Version: "v1"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to register the unversioned types to the Scheme, otherwise the API discovery endpoints won't work.
Scheme: scheme, | ||
ParameterCodec: parameterCodec, | ||
NegotiatedSerializer: codecs, | ||
//OptionsExternalVersion: &schema.GroupVersion{Version: "v1"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can deprecate this field.
Without commenting it out, the API installation of apisever/v1alpha1 will fail with "no type ExportOptions is registered for v1". This error doesn't occur when installing other k8s APIs because their registry use the k8s.io/kubernetes/pkg/api.Scheme, which installs these metav1 types to all versions, including "v1".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm - we will need this in the future - it's intended to control what version of generic APIs are defaulted by the server, like the forthcoming Table.
Meta types should be registered in your group for now - is there a reason you don't want to?
5274cdb
to
5a4e9b9
Compare
// RuleWithVerbs is a tuple of Verbs and Resources. It is recommended to make | ||
// sure that all the tuple expansions are valid. | ||
type RuleWithVerbs struct { | ||
// Verbs is the verbs the admission hook cares about - CREATE, UPDATE, or * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we call it Verbs or Operations? rbac calls is Verbs, and the authorizer interface call it Verbs, but the admission interface calls it Operations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whitlockjc and I lean towards Operations
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
limitations under the License. | ||
*/ | ||
|
||
package externaladmissionhookconfiguration // import "k8s.io/kubernetes/pkg/registry/apiserver/externaladmissionhookconfiguration" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I really object to having a specific API type living in the generic apiserver's registry package. @deads2k did you really want this? ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, Chao is going to move these registry classes into the main repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I really object to having a specific API type living in the generic apiserver's registry package. @deads2k did you really want this? ..
I really want to have separate buckets for "generic API server types" and "kube-apiserver types". The types are two distinct buckets. It's easy to have separate buckets and later move them around. It's really hard to put it all into one bucket and then later try to separate some stuff that was mixed in the bucket. Because of that, putting them here is much easier to change than putting them in the main repo.
The first thing you're going to do is claim that the apiserver needs them and so you'll group them in a k8s.io/apis
bucket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about an alternative where we actually model it as a separate API server that is added to the filter chain like we've done with kube-apiextensions-server
? The integration ends up clean and these stay out of kube-apiserver
. Until we get the third bucket, the types can live here to avoid a cyclical dependency, but my concerns about "making mud" in the shared API would be ameliorated and you'd have a clear delineation for a proper move once the cycle was resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not generic apiserver types, though. The registration api is only going to be hosted by the main apiserver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But are not the same category of thing as the bucket you are going to place them into for the sake of expedience and I sincerely doubt that any separation will ever be made, so this would live forever alongside jobs, hpas, pod disruption budgets, and a host of other APIs it doesn't belong with.
I think its a real shame to do this, you can't easily unmake soup, but ultimately I'm not willing to sacrifice the feature to keep separate things separate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not generic apiserver types, though. The registration api is only going to be hosted by the main apiserver.
[edit] I think this is a strong argument to not put the api in k8s.io/apiserver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would live forever alongside jobs, hpas, pod disruption budgets,
I agree. Admission configuration doesn't blend with jobs, hpa, etc. But currently we don't have another place to put API that is served by the apiserver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Admission configuration doesn't blend with jobs, hpa, etc. But currently we don't have another place to put API that is served by the apiserver.
I'd prefer to see that place built for something net-new than continue a pattern of placing largely unrelated APIs into the same bucket. It's net new, so no one is going to complain that their cheese moved. If we can't make "the right" place, keeping it logically separate in a less than ideal location (here), makes it possible to move this later with minimal complaint. If we go in the other direction (put it into k8s.io/kubernetes/pkg/apis), then we are extremely unlikely to correct it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new place would be best, but we don't have time to build a new place IMO. As long as it's in its own group...
IMO this is a level 2 code separation concern, and we still haven't finished the level 1 code separation.
defaulter-gen never worked for any staging repo... if we decided to keep the api in k8s.io/apiserver, we'll need to update k8s.io/gengo, and then vendor it back. |
8067154
to
48c205e
Compare
Can I get some reviews for the "api" commit? Other commits will change if we decide to move the api to k8s.io/kubernetes. |
@@ -46,3 +48,190 @@ type AdmissionPluginConfiguration struct { | |||
// +optional | |||
Configuration runtime.Object | |||
} | |||
|
|||
// InitializerConfiguration and ExternalAdmissionHookConfiguration is for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this in doc.go
Name string | ||
|
||
// Rules describes what resources/subresources the initializer cares about. | ||
// The intializer cares about an operation if it matches _any_ Rule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
Rule | ||
} | ||
|
||
type OperationType string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment that operations must match admission.Attributes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments on validation
|
||
func validateInitializer(initializer *apiserver.Initializer, fldPath *field.Path) field.ErrorList { | ||
var allErrors field.ErrorList | ||
// TODO: update IsQualifiedName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update what about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deads2k the code history is lost during the move to staging. It looks like we used to have a completely different criteria on QualifiedName. Shall I create my own function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
}, | ||
}), | ||
}, | ||
// TODO: add a test checks not fully-qualified initializer name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please implement this todo
expectedError: "apiVersions: Required value", | ||
}, | ||
{ | ||
name: "Resources must not be empty slice", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not? do we really need to distinguish between empty and nil?
expectedError string | ||
}{ | ||
{ | ||
name: "Operations must not be empty slice", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(maybe 'empty or nil'?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, should be empty or nil
. Done.
Addressed @lavalamp and @smarterclayton's comments in the last two commits. PTAL. The remaining disagreement is on where to put the API group: #46294 (comment). |
2a7bbd8
to
2bb97b3
Compare
eff4776
to
dd538b0
Compare
Tests should be fixed. Adding back the lgtm label. |
dd538b0
to
21bb3ad
Compare
21bb3ad
to
89e506c
Compare
Rebased. |
@caesarxuchao: The following test(s) failed:
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this |
I0526 00:56:10.391] # k8s.io/kubernetes/test/e2e_node |
Hahahaha
…On Fri, May 26, 2017 at 3:40 PM, Daniel Smith ***@***.***> wrote:
I0526 00:56:10.391] # k8s.io/kubernetes/test/e2e_node
I0526 00:56:10.391] test/e2e_node/summary_test.go:138: constant
100000000000 overflows int
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#46294 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_pxLdV-T45w5ODgqITbamrN1FZZxaks5r9yqvgaJpZM4NkCBS>
.
|
Automatic merge from submit-queue (batch tested with PRs 46383, 45645, 45923, 44884, 46294) |
Generated client has namespace generation, but should be non-namespaced. |
Eh, right. Will send a fix tonight. |
Doesn't block me, so not critical tonight. |
Sent #46668. |
Implementing the api proposed in kubernetes/community#611.
Wiring the code to serve the api via apiserver.