k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/cmd/kube-apiserver/app/aggregator.go (about)

     1  /*
     2  Copyright 2017 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  // Package app does all of the work necessary to create a Kubernetes
    18  // APIServer by binding together the API, master and APIServer infrastructure.
    19  // It can be configured and called directly or via the hyperkube framework.
    20  package app
    21  
    22  import (
    23  	"k8s.io/apimachinery/pkg/runtime/schema"
    24  	controlplaneapiserver "k8s.io/kubernetes/pkg/controlplane/apiserver"
    25  )
    26  
    27  // The proper way to resolve this letting the aggregator know the desired group and version-within-group order of the underlying servers
    28  // is to refactor the genericapiserver.DelegationTarget to include a list of priorities based on which APIs were installed.
    29  // 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.
    30  // 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.
    31  var apiVersionPriorities = merge(controlplaneapiserver.DefaultGenericAPIServicePriorities(), map[schema.GroupVersion]controlplaneapiserver.APIServicePriority{
    32  	{Group: "", Version: "v1"}: {Group: 18000, Version: 1},
    33  	// to my knowledge, nothing below here collides
    34  	{Group: "apps", Version: "v1"}:                    {Group: 17800, Version: 15},
    35  	{Group: "autoscaling", Version: "v1"}:             {Group: 17500, Version: 15},
    36  	{Group: "autoscaling", Version: "v2"}:             {Group: 17500, Version: 30},
    37  	{Group: "autoscaling", Version: "v2beta1"}:        {Group: 17500, Version: 9},
    38  	{Group: "autoscaling", Version: "v2beta2"}:        {Group: 17500, Version: 1},
    39  	{Group: "batch", Version: "v1"}:                   {Group: 17400, Version: 15},
    40  	{Group: "batch", Version: "v1beta1"}:              {Group: 17400, Version: 9},
    41  	{Group: "batch", Version: "v2alpha1"}:             {Group: 17400, Version: 9},
    42  	{Group: "networking.k8s.io", Version: "v1"}:       {Group: 17200, Version: 15},
    43  	{Group: "networking.k8s.io", Version: "v1alpha1"}: {Group: 17200, Version: 1},
    44  	{Group: "policy", Version: "v1"}:                  {Group: 17100, Version: 15},
    45  	{Group: "policy", Version: "v1beta1"}:             {Group: 17100, Version: 9},
    46  	{Group: "storage.k8s.io", Version: "v1"}:          {Group: 16800, Version: 15},
    47  	{Group: "storage.k8s.io", Version: "v1beta1"}:     {Group: 16800, Version: 9},
    48  	{Group: "storage.k8s.io", Version: "v1alpha1"}:    {Group: 16800, Version: 1},
    49  	{Group: "scheduling.k8s.io", Version: "v1"}:       {Group: 16600, Version: 15},
    50  	{Group: "node.k8s.io", Version: "v1"}:             {Group: 16300, Version: 15},
    51  	{Group: "node.k8s.io", Version: "v1alpha1"}:       {Group: 16300, Version: 1},
    52  	{Group: "node.k8s.io", Version: "v1beta1"}:        {Group: 16300, Version: 9},
    53  	// Append a new group to the end of the list if unsure.
    54  	// You can use min(existing group)-100 as the initial value for a group.
    55  	// Version can be set to 9 (to have space around) for a new group.
    56  })
    57  
    58  func merge(a, b map[schema.GroupVersion]controlplaneapiserver.APIServicePriority) map[schema.GroupVersion]controlplaneapiserver.APIServicePriority {
    59  	for k, v := range b {
    60  		a[k] = v
    61  	}
    62  	return a
    63  }