Skip to content
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

update kube-controller-manager and kube-scheduler to match kube-apiserver defaults #88663

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/cloud-controller-manager/app/options/options_test.go
Expand Up @@ -61,6 +61,7 @@ func TestDefaultFlags(t *testing.T) {
},
Debugging: &cmoptions.DebuggingOptions{
DebuggingConfiguration: &componentbaseconfig.DebuggingConfiguration{
EnableProfiling: true,
EnableContentionProfiling: false,
},
},
Expand Down Expand Up @@ -192,6 +193,7 @@ func TestAddFlags(t *testing.T) {
},
Debugging: &cmoptions.DebuggingOptions{
DebuggingConfiguration: &componentbaseconfig.DebuggingConfiguration{
EnableProfiling: false,
EnableContentionProfiling: true,
},
},
Expand Down
10 changes: 10 additions & 0 deletions cmd/controller-manager/app/options/debugging.go
Expand Up @@ -27,6 +27,16 @@ type DebuggingOptions struct {
*componentbaseconfig.DebuggingConfiguration
}

// RecommendedDebuggingOptions returns the currently recommended debugging options. These are subject to change
// between releases as we add options and decide which features should be exposed or not by default.
func RecommendedDebuggingOptions() *DebuggingOptions {
return &DebuggingOptions{
DebuggingConfiguration: &componentbaseconfig.DebuggingConfiguration{
EnableProfiling: true, // profile debugging is cheap to have exposed and standard on kube binaries
},
}
}

// AddFlags adds flags related to debugging for controller manager to the specified FlagSet.
func (o *DebuggingOptions) AddFlags(fs *pflag.FlagSet) {
if o == nil {
Expand Down
5 changes: 1 addition & 4 deletions cmd/controller-manager/app/options/generic.go
Expand Up @@ -22,7 +22,6 @@ import (

"k8s.io/apimachinery/pkg/util/sets"
cliflag "k8s.io/component-base/cli/flag"
componentbaseconfig "k8s.io/component-base/config"
"k8s.io/kubernetes/pkg/client/leaderelectionconfig"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
)
Expand All @@ -39,9 +38,7 @@ type GenericControllerManagerConfigurationOptions struct {
func NewGenericControllerManagerConfigurationOptions(cfg *kubectrlmgrconfig.GenericControllerManagerConfiguration) *GenericControllerManagerConfigurationOptions {
o := &GenericControllerManagerConfigurationOptions{
GenericControllerManagerConfiguration: cfg,
Debugging: &DebuggingOptions{
DebuggingConfiguration: &componentbaseconfig.DebuggingConfiguration{},
},
Debugging: RecommendedDebuggingOptions(),
}

return o
Expand Down
1 change: 1 addition & 0 deletions cmd/kube-scheduler/app/options/BUILD
Expand Up @@ -42,6 +42,7 @@ go_library(
"//staging/src/k8s.io/component-base/cli/flag:go_default_library",
"//staging/src/k8s.io/component-base/codec:go_default_library",
"//staging/src/k8s.io/component-base/config:go_default_library",
"//staging/src/k8s.io/component-base/config/v1alpha1:go_default_library",
"//staging/src/k8s.io/component-base/metrics:go_default_library",
"//staging/src/k8s.io/kube-scheduler/config/v1alpha2:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
Expand Down
3 changes: 3 additions & 0 deletions cmd/kube-scheduler/app/options/options.go
Expand Up @@ -39,6 +39,7 @@ import (
"k8s.io/client-go/tools/record"
cliflag "k8s.io/component-base/cli/flag"
componentbaseconfig "k8s.io/component-base/config"
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
"k8s.io/component-base/metrics"
"k8s.io/klog"
kubeschedulerconfigv1alpha2 "k8s.io/kube-scheduler/config/v1alpha2"
Expand Down Expand Up @@ -136,6 +137,8 @@ func splitHostIntPort(s string) (string, int, error) {

func newDefaultComponentConfig() (*kubeschedulerconfig.KubeSchedulerConfiguration, error) {
versionedCfg := kubeschedulerconfigv1alpha2.KubeSchedulerConfiguration{}
versionedCfg.DebuggingConfiguration = *configv1alpha1.NewRecommendedDebuggingConfiguration()

kubeschedulerscheme.Scheme.Default(&versionedCfg)
cfg := kubeschedulerconfig.KubeSchedulerConfiguration{}
if err := kubeschedulerscheme.Scheme.Convert(&versionedCfg, &cfg, nil); err != nil {
Expand Down
23 changes: 23 additions & 0 deletions staging/src/k8s.io/component-base/config/v1alpha1/defaults.go
Expand Up @@ -72,3 +72,26 @@ func RecommendedDefaultClientConnectionConfiguration(obj *ClientConnectionConfig
obj.Burst = 100
}
}

// RecommendedDebuggingConfiguration defaults profiling and debugging configuration.
// This will set the recommended default
// values, but they may be subject to change between API versions. This function
// is intentionally not registered in the scheme as a "normal" `SetDefaults_Foo`
// function to allow consumers of this type to set whatever defaults for their
// embedded configs. Forcing consumers to use these defaults would be problematic
// as defaulting in the scheme is done as part of the conversion, and there would
// be no easy way to opt-out. Instead, if you want to use this defaulting method
// run it in your wrapper struct of this type in its `SetDefaults_` method.
func RecommendedDebuggingConfiguration(obj *DebuggingConfiguration) {
if obj.EnableProfiling == nil {
obj.EnableProfiling = utilpointer.BoolPtr(true) // profile debugging is cheap to have exposed and standard on kube binaries
}
}

// NewRecommendedDebuggingConfiguration returns the current recommended DebuggingConfiguration.
// This may change between releases as recommendations shift.
func NewRecommendedDebuggingConfiguration() *DebuggingConfiguration {
ret := &DebuggingConfiguration{}
RecommendedDebuggingConfiguration(ret)
return ret
}