mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #41085 from deads2k/apiserver-07-move-runtime-config
Automatic merge from submit-queue (batch tested with PRs 41061, 40888, 40664, 41020, 41085) move --runtime-config to kubeapiserver `--runtime-config` is only useful if you have a lot of API groups in one server. If you have a single API group in your server (the vast majority of aggregated API servers), then the flag is unneeded and relatively complex. This moves it to closer to point of use. @sttts
This commit is contained in:
commit
01c45f7de1
@ -48,6 +48,7 @@ type ServerRunOptions struct {
|
|||||||
Authorization *kubeoptions.BuiltInAuthorizationOptions
|
Authorization *kubeoptions.BuiltInAuthorizationOptions
|
||||||
CloudProvider *kubeoptions.CloudProviderOptions
|
CloudProvider *kubeoptions.CloudProviderOptions
|
||||||
StorageSerialization *kubeoptions.StorageSerializationOptions
|
StorageSerialization *kubeoptions.StorageSerializationOptions
|
||||||
|
APIEnablement *kubeoptions.APIEnablementOptions
|
||||||
|
|
||||||
AllowPrivileged bool
|
AllowPrivileged bool
|
||||||
EventTTL time.Duration
|
EventTTL time.Duration
|
||||||
@ -72,6 +73,7 @@ func NewServerRunOptions() *ServerRunOptions {
|
|||||||
Authorization: kubeoptions.NewBuiltInAuthorizationOptions(),
|
Authorization: kubeoptions.NewBuiltInAuthorizationOptions(),
|
||||||
CloudProvider: kubeoptions.NewCloudProviderOptions(),
|
CloudProvider: kubeoptions.NewCloudProviderOptions(),
|
||||||
StorageSerialization: kubeoptions.NewStorageSerializationOptions(),
|
StorageSerialization: kubeoptions.NewStorageSerializationOptions(),
|
||||||
|
APIEnablement: kubeoptions.NewAPIEnablementOptions(),
|
||||||
|
|
||||||
EventTTL: 1 * time.Hour,
|
EventTTL: 1 * time.Hour,
|
||||||
MasterCount: 1,
|
MasterCount: 1,
|
||||||
@ -107,6 +109,7 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
|
|||||||
s.Authorization.AddFlags(fs)
|
s.Authorization.AddFlags(fs)
|
||||||
s.CloudProvider.AddFlags(fs)
|
s.CloudProvider.AddFlags(fs)
|
||||||
s.StorageSerialization.AddFlags(fs)
|
s.StorageSerialization.AddFlags(fs)
|
||||||
|
s.APIEnablement.AddFlags(fs)
|
||||||
|
|
||||||
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
|
// Note: the weird ""+ in below lines seems to be the only way to get gofmt to
|
||||||
// arrange these text blocks sensibly. Grrr.
|
// arrange these text blocks sensibly. Grrr.
|
||||||
|
@ -203,7 +203,7 @@ func Run(s *options.ServerRunOptions) error {
|
|||||||
genericapiserver.NewDefaultResourceEncodingConfig(api.Registry), storageGroupsToEncodingVersion,
|
genericapiserver.NewDefaultResourceEncodingConfig(api.Registry), storageGroupsToEncodingVersion,
|
||||||
// FIXME: this GroupVersionResource override should be configurable
|
// FIXME: this GroupVersionResource override should be configurable
|
||||||
[]schema.GroupVersionResource{batch.Resource("cronjobs").WithVersion("v2alpha1")},
|
[]schema.GroupVersionResource{batch.Resource("cronjobs").WithVersion("v2alpha1")},
|
||||||
master.DefaultAPIResourceConfigSource(), s.GenericServerRunOptions.RuntimeConfig)
|
master.DefaultAPIResourceConfigSource(), s.APIEnablement.RuntimeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error in initializing storage factory: %s", err)
|
return fmt.Errorf("error in initializing storage factory: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ type ServerRunOptions struct {
|
|||||||
Authorization *kubeoptions.BuiltInAuthorizationOptions
|
Authorization *kubeoptions.BuiltInAuthorizationOptions
|
||||||
CloudProvider *kubeoptions.CloudProviderOptions
|
CloudProvider *kubeoptions.CloudProviderOptions
|
||||||
StorageSerialization *kubeoptions.StorageSerializationOptions
|
StorageSerialization *kubeoptions.StorageSerializationOptions
|
||||||
|
APIEnablement *kubeoptions.APIEnablementOptions
|
||||||
|
|
||||||
EventTTL time.Duration
|
EventTTL time.Duration
|
||||||
}
|
}
|
||||||
@ -55,6 +56,7 @@ func NewServerRunOptions() *ServerRunOptions {
|
|||||||
Authorization: kubeoptions.NewBuiltInAuthorizationOptions(),
|
Authorization: kubeoptions.NewBuiltInAuthorizationOptions(),
|
||||||
CloudProvider: kubeoptions.NewCloudProviderOptions(),
|
CloudProvider: kubeoptions.NewCloudProviderOptions(),
|
||||||
StorageSerialization: kubeoptions.NewStorageSerializationOptions(),
|
StorageSerialization: kubeoptions.NewStorageSerializationOptions(),
|
||||||
|
APIEnablement: kubeoptions.NewAPIEnablementOptions(),
|
||||||
|
|
||||||
EventTTL: 1 * time.Hour,
|
EventTTL: 1 * time.Hour,
|
||||||
}
|
}
|
||||||
@ -74,6 +76,7 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) {
|
|||||||
s.Authorization.AddFlags(fs)
|
s.Authorization.AddFlags(fs)
|
||||||
s.CloudProvider.AddFlags(fs)
|
s.CloudProvider.AddFlags(fs)
|
||||||
s.StorageSerialization.AddFlags(fs)
|
s.StorageSerialization.AddFlags(fs)
|
||||||
|
s.APIEnablement.AddFlags(fs)
|
||||||
|
|
||||||
fs.DurationVar(&s.EventTTL, "event-ttl", s.EventTTL,
|
fs.DurationVar(&s.EventTTL, "event-ttl", s.EventTTL,
|
||||||
"Amount of time to retain events. Default is 1h.")
|
"Amount of time to retain events. Default is 1h.")
|
||||||
|
@ -118,7 +118,7 @@ func Run(s *options.ServerRunOptions) error {
|
|||||||
storageFactory, err := kubeapiserver.BuildDefaultStorageFactory(
|
storageFactory, err := kubeapiserver.BuildDefaultStorageFactory(
|
||||||
s.Etcd.StorageConfig, s.GenericServerRunOptions.DefaultStorageMediaType, api.Codecs,
|
s.Etcd.StorageConfig, s.GenericServerRunOptions.DefaultStorageMediaType, api.Codecs,
|
||||||
genericapiserver.NewDefaultResourceEncodingConfig(api.Registry), storageGroupsToEncodingVersion,
|
genericapiserver.NewDefaultResourceEncodingConfig(api.Registry), storageGroupsToEncodingVersion,
|
||||||
[]schema.GroupVersionResource{}, resourceConfig, s.GenericServerRunOptions.RuntimeConfig)
|
[]schema.GroupVersionResource{}, resourceConfig, s.APIEnablement.RuntimeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error in initializing storage factory: %s", err)
|
return fmt.Errorf("error in initializing storage factory: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ load(
|
|||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
"api_enablement.go",
|
||||||
"authentication.go",
|
"authentication.go",
|
||||||
"authorization.go",
|
"authorization.go",
|
||||||
"cloudprovider.go",
|
"cloudprovider.go",
|
||||||
@ -29,6 +30,7 @@ go_library(
|
|||||||
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
|
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
|
||||||
"//vendor:k8s.io/apiserver/pkg/server",
|
"//vendor:k8s.io/apiserver/pkg/server",
|
||||||
"//vendor:k8s.io/apiserver/pkg/server/options",
|
"//vendor:k8s.io/apiserver/pkg/server/options",
|
||||||
|
"//vendor:k8s.io/apiserver/pkg/util/flag",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
44
pkg/kubeapiserver/options/api_enablement.go
Normal file
44
pkg/kubeapiserver/options/api_enablement.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 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 options
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
|
utilflag "k8s.io/apiserver/pkg/util/flag"
|
||||||
|
)
|
||||||
|
|
||||||
|
// APIEnablementOptions contains the options for which resources to turn on and off.
|
||||||
|
// Given small aggregated API servers, this option isn't required for "normal" API servers
|
||||||
|
type APIEnablementOptions struct {
|
||||||
|
RuntimeConfig utilflag.ConfigurationMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAPIEnablementOptions() *APIEnablementOptions {
|
||||||
|
return &APIEnablementOptions{
|
||||||
|
RuntimeConfig: make(utilflag.ConfigurationMap),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddFlags adds flags for a specific APIServer to the specified FlagSet
|
||||||
|
func (s *APIEnablementOptions) AddFlags(fs *pflag.FlagSet) {
|
||||||
|
fs.Var(&s.RuntimeConfig, "runtime-config", ""+
|
||||||
|
"A set of key=value pairs that describe runtime configuration that may be passed "+
|
||||||
|
"to apiserver. apis/<groupVersion> key can be used to turn on/off specific api versions. "+
|
||||||
|
"apis/<groupVersion>/<resource> can be used to turn on/off specific resources. api/all and "+
|
||||||
|
"api/legacy are special keys to control all and legacy api versions respectively.")
|
||||||
|
}
|
@ -25,7 +25,6 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/admission"
|
"k8s.io/apiserver/pkg/admission"
|
||||||
"k8s.io/apiserver/pkg/server"
|
"k8s.io/apiserver/pkg/server"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
utilflag "k8s.io/apiserver/pkg/util/flag"
|
|
||||||
|
|
||||||
// add the generic feature gates
|
// add the generic feature gates
|
||||||
_ "k8s.io/apiserver/pkg/features"
|
_ "k8s.io/apiserver/pkg/features"
|
||||||
@ -58,7 +57,6 @@ type ServerRunOptions struct {
|
|||||||
MaxRequestsInFlight int
|
MaxRequestsInFlight int
|
||||||
MaxMutatingRequestsInFlight int
|
MaxMutatingRequestsInFlight int
|
||||||
MinRequestTimeout int
|
MinRequestTimeout int
|
||||||
RuntimeConfig utilflag.ConfigurationMap
|
|
||||||
TargetRAMMB int
|
TargetRAMMB int
|
||||||
WatchCacheSizes []string
|
WatchCacheSizes []string
|
||||||
}
|
}
|
||||||
@ -77,7 +75,6 @@ func NewServerRunOptions() *ServerRunOptions {
|
|||||||
MaxRequestsInFlight: defaults.MaxRequestsInFlight,
|
MaxRequestsInFlight: defaults.MaxRequestsInFlight,
|
||||||
MaxMutatingRequestsInFlight: defaults.MaxMutatingRequestsInFlight,
|
MaxMutatingRequestsInFlight: defaults.MaxMutatingRequestsInFlight,
|
||||||
MinRequestTimeout: defaults.MinRequestTimeout,
|
MinRequestTimeout: defaults.MinRequestTimeout,
|
||||||
RuntimeConfig: make(utilflag.ConfigurationMap),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,12 +215,6 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
|
|||||||
"handler, which picks a randomized value above this number as the connection timeout, "+
|
"handler, which picks a randomized value above this number as the connection timeout, "+
|
||||||
"to spread out load.")
|
"to spread out load.")
|
||||||
|
|
||||||
fs.Var(&s.RuntimeConfig, "runtime-config", ""+
|
|
||||||
"A set of key=value pairs that describe runtime configuration that may be passed "+
|
|
||||||
"to apiserver. apis/<groupVersion> key can be used to turn on/off specific api versions. "+
|
|
||||||
"apis/<groupVersion>/<resource> can be used to turn on/off specific resources. api/all and "+
|
|
||||||
"api/legacy are special keys to control all and legacy api versions respectively.")
|
|
||||||
|
|
||||||
fs.StringSliceVar(&s.WatchCacheSizes, "watch-cache-sizes", s.WatchCacheSizes, ""+
|
fs.StringSliceVar(&s.WatchCacheSizes, "watch-cache-sizes", s.WatchCacheSizes, ""+
|
||||||
"List of watch cache sizes for every resource (pods, nodes, etc.), comma separated. "+
|
"List of watch cache sizes for every resource (pods, nodes, etc.), comma separated. "+
|
||||||
"The individual override format: resource#size, where size is a number. It takes effect "+
|
"The individual override format: resource#size, where size is a number. It takes effect "+
|
||||||
|
Loading…
Reference in New Issue
Block a user