remove CAdvisorPort from KubeletConfiguration

See: #56523, cAdvisor is becoming an implementation detail of
Kubernetes, and we should not canonize its knobs on the
KubeletConfiguration.
This commit is contained in:
Michael Taufen 2018-02-08 09:35:38 -08:00
parent c15ae2fff7
commit 5ab9ccd4fb
15 changed files with 13 additions and 41 deletions

View File

@ -72,7 +72,6 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
Authentication: kubeletconfigv1alpha1.KubeletAuthentication{ Authentication: kubeletconfigv1alpha1.KubeletAuthentication{
X509: kubeletconfigv1alpha1.KubeletX509Authentication{ClientCAFile: "foo"}, X509: kubeletconfigv1alpha1.KubeletX509Authentication{ClientCAFile: "foo"},
}, },
CAdvisorPort: utilpointer.Int32Ptr(0),
}, },
} }
kubeletconfigv1alpha1.SetDefaults_KubeletConfiguration(obj.KubeletConfiguration.BaseConfig) kubeletconfigv1alpha1.SetDefaults_KubeletConfiguration(obj.KubeletConfiguration.BaseConfig)

View File

@ -56,7 +56,6 @@ go_library(
"//pkg/kubelet/apis/kubeletconfig/v1alpha1:go_default_library", "//pkg/kubelet/apis/kubeletconfig/v1alpha1:go_default_library",
"//pkg/proxy/apis/kubeproxyconfig/scheme:go_default_library", "//pkg/proxy/apis/kubeproxyconfig/scheme:go_default_library",
"//pkg/proxy/apis/kubeproxyconfig/v1alpha1:go_default_library", "//pkg/proxy/apis/kubeproxyconfig/v1alpha1:go_default_library",
"//pkg/util/pointer:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library", "//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",

View File

@ -28,7 +28,6 @@ import (
kubeletconfigv1alpha1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1alpha1" kubeletconfigv1alpha1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1alpha1"
kubeproxyscheme "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/scheme" kubeproxyscheme "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/scheme"
kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/v1alpha1" kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/v1alpha1"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
) )
const ( const (
@ -202,9 +201,6 @@ func SetDefaults_KubeletConfiguration(obj *MasterConfiguration) {
if obj.KubeletConfiguration.BaseConfig.Authentication.X509.ClientCAFile == "" { if obj.KubeletConfiguration.BaseConfig.Authentication.X509.ClientCAFile == "" {
obj.KubeletConfiguration.BaseConfig.Authentication.X509.ClientCAFile = DefaultCACertPath obj.KubeletConfiguration.BaseConfig.Authentication.X509.ClientCAFile = DefaultCACertPath
} }
if obj.KubeletConfiguration.BaseConfig.CAdvisorPort == nil {
obj.KubeletConfiguration.BaseConfig.CAdvisorPort = utilpointer.Int32Ptr(0)
}
scheme, _, _ := kubeletscheme.NewSchemeAndCodecs() scheme, _, _ := kubeletscheme.NewSchemeAndCodecs()
if scheme != nil { if scheme != nil {

View File

@ -573,7 +573,6 @@ func TestValidateKubeletConfiguration(t *testing.T) {
EnforceNodeAllocatable: []string{"pods", "system-reserved", "kube-reserved"}, EnforceNodeAllocatable: []string{"pods", "system-reserved", "kube-reserved"},
SystemCgroups: "", SystemCgroups: "",
CgroupRoot: "", CgroupRoot: "",
CAdvisorPort: utilpointer.Int32Ptr(0),
EventBurst: 10, EventBurst: 10,
EventRecordQPS: utilpointer.Int32Ptr(5), EventRecordQPS: utilpointer.Int32Ptr(5),
HealthzPort: utilpointer.Int32Ptr(10248), HealthzPort: utilpointer.Int32Ptr(10248),
@ -604,7 +603,6 @@ func TestValidateKubeletConfiguration(t *testing.T) {
EnforceNodeAllocatable: []string{"pods", "system-reserved", "kube-reserved", "illegal-key"}, EnforceNodeAllocatable: []string{"pods", "system-reserved", "kube-reserved", "illegal-key"},
SystemCgroups: "/", SystemCgroups: "/",
CgroupRoot: "", CgroupRoot: "",
CAdvisorPort: utilpointer.Int32Ptr(-10),
EventBurst: -10, EventBurst: -10,
EventRecordQPS: utilpointer.Int32Ptr(-10), EventRecordQPS: utilpointer.Int32Ptr(-10),
HealthzPort: utilpointer.Int32Ptr(-10), HealthzPort: utilpointer.Int32Ptr(-10),

View File

@ -66,6 +66,7 @@ go_library(
"//vendor/github.com/golang/glog:go_default_library", "//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library", "//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library", "//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library", "//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/logs:go_default_library", "//vendor/k8s.io/apiserver/pkg/util/logs:go_default_library",

View File

@ -27,6 +27,7 @@ import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/apiserver/pkg/util/flag" "k8s.io/apiserver/pkg/util/flag"
"k8s.io/kubernetes/pkg/apis/componentconfig" "k8s.io/kubernetes/pkg/apis/componentconfig"
@ -115,6 +116,9 @@ type KubeletFlags struct {
// is true and upon the initial registration of the node. // is true and upon the initial registration of the node.
RegisterWithTaints []core.Taint RegisterWithTaints []core.Taint
// cAdvisorPort is the port of the localhost cAdvisor endpoint (set to 0 to disable)
CAdvisorPort int32
// EXPERIMENTAL FLAGS // EXPERIMENTAL FLAGS
// Whitelist of unsafe sysctls or sysctl patterns (ending in *). // Whitelist of unsafe sysctls or sysctl patterns (ending in *).
// +optional // +optional
@ -232,6 +236,8 @@ func NewKubeletFlags() *KubeletFlags {
HostNetworkSources: []string{kubetypes.AllSource}, HostNetworkSources: []string{kubetypes.AllSource},
HostPIDSources: []string{kubetypes.AllSource}, HostPIDSources: []string{kubetypes.AllSource},
HostIPCSources: []string{kubetypes.AllSource}, HostIPCSources: []string{kubetypes.AllSource},
// TODO(#56523): default CAdvisorPort to 0 (disabled) and deprecate it
CAdvisorPort: 4194,
} }
} }
@ -240,6 +246,9 @@ func ValidateKubeletFlags(f *KubeletFlags) error {
if f.DynamicConfigDir.Provided() && !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) { if f.DynamicConfigDir.Provided() && !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
return fmt.Errorf("the DynamicKubeletConfig feature gate must be enabled in order to use the --dynamic-config-dir flag") return fmt.Errorf("the DynamicKubeletConfig feature gate must be enabled in order to use the --dynamic-config-dir flag")
} }
if f.CAdvisorPort != 0 && utilvalidation.IsValidPortNum(int(f.CAdvisorPort)) != nil {
return fmt.Errorf("invalid configuration: CAdvisorPort (--cadvisor-port) %v must be between 0 and 65535, inclusive", f.CAdvisorPort)
}
return nil return nil
} }
@ -333,6 +342,7 @@ func (f *KubeletFlags) AddFlags(fs *pflag.FlagSet) {
fs.BoolVar(&f.RegisterNode, "register-node", f.RegisterNode, "Register the node with the apiserver. If --kubeconfig is not provided, this flag is irrelevant, as the Kubelet won't have an apiserver to register with. Default=true.") fs.BoolVar(&f.RegisterNode, "register-node", f.RegisterNode, "Register the node with the apiserver. If --kubeconfig is not provided, this flag is irrelevant, as the Kubelet won't have an apiserver to register with. Default=true.")
fs.Var(utiltaints.NewTaintsVar(&f.RegisterWithTaints), "register-with-taints", "Register the node with the given list of taints (comma separated \"<key>=<value>:<effect>\"). No-op if register-node is false.") fs.Var(utiltaints.NewTaintsVar(&f.RegisterWithTaints), "register-with-taints", "Register the node with the given list of taints (comma separated \"<key>=<value>:<effect>\"). No-op if register-node is false.")
fs.BoolVar(&f.Containerized, "containerized", f.Containerized, "Running kubelet in a container.") fs.BoolVar(&f.Containerized, "containerized", f.Containerized, "Running kubelet in a container.")
fs.Int32Var(&f.CAdvisorPort, "cadvisor-port", f.CAdvisorPort, "The port of the localhost cAdvisor endpoint (set to 0 to disable)")
// EXPERIMENTAL FLAGS // EXPERIMENTAL FLAGS
fs.StringVar(&f.KubeletConfigFile, "config", f.KubeletConfigFile, "<Warning: Alpha feature> The Kubelet will load its initial configuration from this file. The path may be absolute or relative; relative paths start at the Kubelet's current working directory. Omit this flag to use the built-in default configuration values. Note that the format of the config file is still Alpha.") fs.StringVar(&f.KubeletConfigFile, "config", f.KubeletConfigFile, "<Warning: Alpha feature> The Kubelet will load its initial configuration from this file. The path may be absolute or relative; relative paths start at the Kubelet's current working directory. Omit this flag to use the built-in default configuration values. Note that the format of the config file is still Alpha.")
@ -444,7 +454,6 @@ func AddKubeletConfigFlags(fs *pflag.FlagSet, c *kubeletconfig.KubeletConfigurat
fs.BoolVar(&c.EnableDebuggingHandlers, "enable-debugging-handlers", c.EnableDebuggingHandlers, "Enables server endpoints for log collection and local running of containers and commands") fs.BoolVar(&c.EnableDebuggingHandlers, "enable-debugging-handlers", c.EnableDebuggingHandlers, "Enables server endpoints for log collection and local running of containers and commands")
fs.BoolVar(&c.EnableContentionProfiling, "contention-profiling", c.EnableContentionProfiling, "Enable lock contention profiling, if profiling is enabled") fs.BoolVar(&c.EnableContentionProfiling, "contention-profiling", c.EnableContentionProfiling, "Enable lock contention profiling, if profiling is enabled")
fs.Int32Var(&c.CAdvisorPort, "cadvisor-port", c.CAdvisorPort, "The port of the localhost cAdvisor endpoint (set to 0 to disable)")
fs.Int32Var(&c.HealthzPort, "healthz-port", c.HealthzPort, "The port of the localhost healthz endpoint (set to 0 to disable)") fs.Int32Var(&c.HealthzPort, "healthz-port", c.HealthzPort, "The port of the localhost healthz endpoint (set to 0 to disable)")
fs.Var(componentconfig.IPVar{Val: &c.HealthzBindAddress}, "healthz-bind-address", "The IP address for the healthz server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)") fs.Var(componentconfig.IPVar{Val: &c.HealthzBindAddress}, "healthz-bind-address", "The IP address for the healthz server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
fs.Int32Var(&c.OOMScoreAdj, "oom-score-adj", c.OOMScoreAdj, "The oom-score-adj value for kubelet process. Values must be within the range [-1000, 1000]") fs.Int32Var(&c.OOMScoreAdj, "oom-score-adj", c.OOMScoreAdj, "The oom-score-adj value for kubelet process. Values must be within the range [-1000, 1000]")

View File

@ -43,7 +43,6 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
obj.Authorization.Webhook.CacheAuthorizedTTL = metav1.Duration{Duration: 5 * time.Minute} obj.Authorization.Webhook.CacheAuthorizedTTL = metav1.Duration{Duration: 5 * time.Minute}
obj.Authorization.Webhook.CacheUnauthorizedTTL = metav1.Duration{Duration: 30 * time.Second} obj.Authorization.Webhook.CacheUnauthorizedTTL = metav1.Duration{Duration: 30 * time.Second}
obj.Address = "0.0.0.0" obj.Address = "0.0.0.0"
obj.CAdvisorPort = 4194
obj.VolumeStatsAggPeriod = metav1.Duration{Duration: time.Minute} obj.VolumeStatsAggPeriod = metav1.Duration{Duration: time.Minute}
obj.RuntimeRequestTimeout = metav1.Duration{Duration: 2 * time.Minute} obj.RuntimeRequestTimeout = metav1.Duration{Duration: 2 * time.Minute}
obj.CPUCFSQuota = true obj.CPUCFSQuota = true

View File

@ -144,7 +144,6 @@ var (
"Authorization.Mode", "Authorization.Mode",
"Authorization.Webhook.CacheAuthorizedTTL.Duration", "Authorization.Webhook.CacheAuthorizedTTL.Duration",
"Authorization.Webhook.CacheUnauthorizedTTL.Duration", "Authorization.Webhook.CacheUnauthorizedTTL.Duration",
"CAdvisorPort",
"CPUCFSQuota", "CPUCFSQuota",
"CPUManagerPolicy", "CPUManagerPolicy",
"CPUManagerReconcilePeriod.Duration", "CPUManagerReconcilePeriod.Duration",

View File

@ -114,8 +114,6 @@ type KubeletConfiguration struct {
EnableDebuggingHandlers bool EnableDebuggingHandlers bool
// enableContentionProfiling enables lock contention profiling, if enableDebuggingHandlers is true. // enableContentionProfiling enables lock contention profiling, if enableDebuggingHandlers is true.
EnableContentionProfiling bool EnableContentionProfiling bool
// cAdvisorPort is the port of the localhost cAdvisor endpoint (set to 0 to disable)
CAdvisorPort int32
// healthzPort is the port of the localhost healthz endpoint (set to 0 to disable) // healthzPort is the port of the localhost healthz endpoint (set to 0 to disable)
HealthzPort int32 HealthzPort int32
// healthzBindAddress is the IP address for the healthz server to serve // healthzBindAddress is the IP address for the healthz server to serve

View File

@ -67,13 +67,9 @@ func SetDefaults_KubeletConfiguration(obj *KubeletConfiguration) {
if obj.Authorization.Webhook.CacheUnauthorizedTTL == zeroDuration { if obj.Authorization.Webhook.CacheUnauthorizedTTL == zeroDuration {
obj.Authorization.Webhook.CacheUnauthorizedTTL = metav1.Duration{Duration: 30 * time.Second} obj.Authorization.Webhook.CacheUnauthorizedTTL = metav1.Duration{Duration: 30 * time.Second}
} }
if obj.Address == "" { if obj.Address == "" {
obj.Address = "0.0.0.0" obj.Address = "0.0.0.0"
} }
if obj.CAdvisorPort == nil {
obj.CAdvisorPort = utilpointer.Int32Ptr(4194)
}
if obj.VolumeStatsAggPeriod == zeroDuration { if obj.VolumeStatsAggPeriod == zeroDuration {
obj.VolumeStatsAggPeriod = metav1.Duration{Duration: time.Minute} obj.VolumeStatsAggPeriod = metav1.Duration{Duration: time.Minute}
} }

View File

@ -114,8 +114,6 @@ type KubeletConfiguration struct {
EnableDebuggingHandlers *bool `json:"enableDebuggingHandlers"` EnableDebuggingHandlers *bool `json:"enableDebuggingHandlers"`
// enableContentionProfiling enables lock contention profiling, if enableDebuggingHandlers is true. // enableContentionProfiling enables lock contention profiling, if enableDebuggingHandlers is true.
EnableContentionProfiling bool `json:"enableContentionProfiling"` EnableContentionProfiling bool `json:"enableContentionProfiling"`
// cAdvisorPort is the port of the localhost cAdvisor endpoint (set to 0 to disable)
CAdvisorPort *int32 `json:"cAdvisorPort"`
// healthzPort is the port of the localhost healthz endpoint (set to 0 to disable) // healthzPort is the port of the localhost healthz endpoint (set to 0 to disable)
HealthzPort *int32 `json:"healthzPort"` HealthzPort *int32 `json:"healthzPort"`
// healthzBindAddress is the IP address for the healthz server to serve // healthzBindAddress is the IP address for the healthz server to serve

View File

@ -180,9 +180,6 @@ func autoConvert_v1alpha1_KubeletConfiguration_To_kubeletconfig_KubeletConfigura
return err return err
} }
out.EnableContentionProfiling = in.EnableContentionProfiling out.EnableContentionProfiling = in.EnableContentionProfiling
if err := v1.Convert_Pointer_int32_To_int32(&in.CAdvisorPort, &out.CAdvisorPort, s); err != nil {
return err
}
if err := v1.Convert_Pointer_int32_To_int32(&in.HealthzPort, &out.HealthzPort, s); err != nil { if err := v1.Convert_Pointer_int32_To_int32(&in.HealthzPort, &out.HealthzPort, s); err != nil {
return err return err
} }
@ -308,9 +305,6 @@ func autoConvert_kubeletconfig_KubeletConfiguration_To_v1alpha1_KubeletConfigura
return err return err
} }
out.EnableContentionProfiling = in.EnableContentionProfiling out.EnableContentionProfiling = in.EnableContentionProfiling
if err := v1.Convert_int32_To_Pointer_int32(&in.CAdvisorPort, &out.CAdvisorPort, s); err != nil {
return err
}
if err := v1.Convert_int32_To_Pointer_int32(&in.HealthzPort, &out.HealthzPort, s); err != nil { if err := v1.Convert_int32_To_Pointer_int32(&in.HealthzPort, &out.HealthzPort, s); err != nil {
return err return err
} }

View File

@ -166,15 +166,6 @@ func (in *KubeletConfiguration) DeepCopyInto(out *KubeletConfiguration) {
**out = **in **out = **in
} }
} }
if in.CAdvisorPort != nil {
in, out := &in.CAdvisorPort, &out.CAdvisorPort
if *in == nil {
*out = nil
} else {
*out = new(int32)
**out = **in
}
}
if in.HealthzPort != nil { if in.HealthzPort != nil {
in, out := &in.HealthzPort, &out.HealthzPort in, out := &in.HealthzPort, &out.HealthzPort
if *in == nil { if *in == nil {

View File

@ -35,9 +35,6 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error
if kc.SystemCgroups != "" && kc.CgroupRoot == "" { if kc.SystemCgroups != "" && kc.CgroupRoot == "" {
allErrors = append(allErrors, fmt.Errorf("invalid configuration: SystemCgroups (--system-cgroups) was specified and CgroupRoot (--cgroup-root) was not specified")) allErrors = append(allErrors, fmt.Errorf("invalid configuration: SystemCgroups (--system-cgroups) was specified and CgroupRoot (--cgroup-root) was not specified"))
} }
if kc.CAdvisorPort != 0 && utilvalidation.IsValidPortNum(int(kc.CAdvisorPort)) != nil {
allErrors = append(allErrors, fmt.Errorf("invalid configuration: CAdvisorPort (--cadvisor-port) %v must be between 0 and 65535, inclusive", kc.CAdvisorPort))
}
if kc.EventBurst < 0 { if kc.EventBurst < 0 {
allErrors = append(allErrors, fmt.Errorf("invalid configuration: EventBurst (--event-burst) %v must not be a negative number", kc.EventBurst)) allErrors = append(allErrors, fmt.Errorf("invalid configuration: EventBurst (--event-burst) %v must not be a negative number", kc.EventBurst))
} }

View File

@ -29,7 +29,6 @@ func TestValidateKubeletConfiguration(t *testing.T) {
EnforceNodeAllocatable: []string{"pods", "system-reserved", "kube-reserved"}, EnforceNodeAllocatable: []string{"pods", "system-reserved", "kube-reserved"},
SystemCgroups: "", SystemCgroups: "",
CgroupRoot: "", CgroupRoot: "",
CAdvisorPort: 0,
EventBurst: 10, EventBurst: 10,
EventRecordQPS: 5, EventRecordQPS: 5,
HealthzPort: 10248, HealthzPort: 10248,
@ -58,7 +57,6 @@ func TestValidateKubeletConfiguration(t *testing.T) {
EnforceNodeAllocatable: []string{"pods", "system-reserved", "kube-reserved", "illegal-key"}, EnforceNodeAllocatable: []string{"pods", "system-reserved", "kube-reserved", "illegal-key"},
SystemCgroups: "/", SystemCgroups: "/",
CgroupRoot: "", CgroupRoot: "",
CAdvisorPort: -10,
EventBurst: -10, EventBurst: -10,
EventRecordQPS: -10, EventRecordQPS: -10,
HealthzPort: -10, HealthzPort: -10,
@ -78,7 +76,7 @@ func TestValidateKubeletConfiguration(t *testing.T) {
RegistryPullQPS: -10, RegistryPullQPS: -10,
HairpinMode: "foo", HairpinMode: "foo",
} }
if allErrors := ValidateKubeletConfiguration(errorCase); len(allErrors.(utilerrors.Aggregate).Errors()) != 22 { if allErrors := ValidateKubeletConfiguration(errorCase); len(allErrors.(utilerrors.Aggregate).Errors()) != 21 {
t.Errorf("expect 22 errors got %v", len(allErrors.(utilerrors.Aggregate).Errors())) t.Errorf("expect 21 errors got %v", len(allErrors.(utilerrors.Aggregate).Errors()))
} }
} }