-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Step 5 – generic controplane: split aggregator API priorities #124613
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Copyright 2024 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package apiserver | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// APIServicePriority defines group priority that is used in discovery. This controls | ||
// group position in the kubectl output. | ||
type APIServicePriority struct { | ||
// Group indicates the order of the group relative to other groups. | ||
Group int32 | ||
// Version indicates the relative order of the Version inside of its group. | ||
Version int32 | ||
} | ||
|
||
// DefaultGenericAPIServicePriorities returns the APIService priorities for generic APIs | ||
func DefaultGenericAPIServicePriorities() map[schema.GroupVersion]APIServicePriority { | ||
// The proper way to resolve this letting the aggregator know the desired group and version-within-group order of the underlying servers | ||
// is to refactor the genericapiserver.DelegationTarget to include a list of priorities based on which APIs were installed. | ||
// This requires the APIGroupInfo struct to evolve and include the concept of priorities and to avoid mistakes, the core storage map there needs to be updated. | ||
// That ripples out every bit as far as you'd expect, so for 1.7 we'll include the list here instead of being built up during storage. | ||
return map[schema.GroupVersion]APIServicePriority{ | ||
{Group: "", Version: "v1"}: {Group: 18000, Version: 1}, | ||
// to my knowledge, nothing below here collides | ||
{Group: "events.k8s.io", Version: "v1"}: {Group: 17750, Version: 15}, | ||
{Group: "events.k8s.io", Version: "v1beta1"}: {Group: 17750, Version: 5}, | ||
{Group: "authentication.k8s.io", Version: "v1"}: {Group: 17700, Version: 15}, | ||
{Group: "authentication.k8s.io", Version: "v1beta1"}: {Group: 17700, Version: 9}, | ||
{Group: "authentication.k8s.io", Version: "v1alpha1"}: {Group: 17700, Version: 1}, | ||
{Group: "authorization.k8s.io", Version: "v1"}: {Group: 17600, Version: 15}, | ||
{Group: "certificates.k8s.io", Version: "v1"}: {Group: 17300, Version: 15}, | ||
{Group: "certificates.k8s.io", Version: "v1alpha1"}: {Group: 17300, Version: 1}, | ||
{Group: "rbac.authorization.k8s.io", Version: "v1"}: {Group: 17000, Version: 15}, | ||
{Group: "apiextensions.k8s.io", Version: "v1"}: {Group: 16700, Version: 15}, | ||
{Group: "admissionregistration.k8s.io", Version: "v1"}: {Group: 16700, Version: 15}, | ||
{Group: "admissionregistration.k8s.io", Version: "v1beta1"}: {Group: 16700, Version: 12}, | ||
{Group: "admissionregistration.k8s.io", Version: "v1alpha1"}: {Group: 16700, Version: 9}, | ||
{Group: "coordination.k8s.io", Version: "v1"}: {Group: 16500, Version: 15}, | ||
{Group: "discovery.k8s.io", Version: "v1"}: {Group: 16200, Version: 15}, | ||
{Group: "discovery.k8s.io", Version: "v1beta1"}: {Group: 16200, Version: 12}, | ||
{Group: "flowcontrol.apiserver.k8s.io", Version: "v1"}: {Group: 16100, Version: 21}, | ||
{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta3"}: {Group: 16100, Version: 18}, | ||
{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta2"}: {Group: 16100, Version: 15}, | ||
{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta1"}: {Group: 16100, Version: 12}, | ||
{Group: "flowcontrol.apiserver.k8s.io", Version: "v1alpha1"}: {Group: 16100, Version: 9}, | ||
{Group: "internal.apiserver.k8s.io", Version: "v1alpha1"}: {Group: 16000, Version: 9}, | ||
{Group: "resource.k8s.io", Version: "v1alpha2"}: {Group: 15900, Version: 9}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really generic? This seems to be related to Dynamic Resource Allocation, which is pod-specific if I'm not mistaken? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. I can see it has few types we might want to use in building some quota machinery: |
||
{Group: "storagemigration.k8s.io", Version: "v1alpha1"}: {Group: 15800, Version: 9}, | ||
// Append a new group to the end of the list if unsure. | ||
// You can use min(existing group)-100 as the initial value for a group. | ||
// Version can be set to 9 (to have space around) for a new group. | ||
} | ||
} |
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.
now it's not a problem, but I was first thinking that it could be problematic if this function would be passed some generic global variable, as this func mutates
a
. You indeed solved it with having a function returning a new variable every time, but just something to be careful about, unless this function first does a deep copy of a.