diff --git a/cmd/cloud-controller-manager/app/apis/config/v1alpha1/doc.go b/cmd/cloud-controller-manager/app/apis/config/v1alpha1/doc.go index 1779b1fad0..6522975cc1 100644 --- a/cmd/cloud-controller-manager/app/apis/config/v1alpha1/doc.go +++ b/cmd/cloud-controller-manager/app/apis/config/v1alpha1/doc.go @@ -21,8 +21,7 @@ limitations under the License. // +k8s:deepcopy-gen=package // +k8s:conversion-gen=k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config -// +k8s:conversion-gen=k8s.io/apimachinery/pkg/apis/config/v1alpha1 -// +k8s:conversion-gen=k8s.io/apiserver/pkg/apis/config/v1alpha1 +// +k8s:conversion-gen=k8s.io/component-base/config/v1alpha1 // +k8s:conversion-gen=k8s.io/kubernetes/pkg/controller/apis/config/v1alpha1 // +k8s:openapi-gen=true // +k8s:defaulter-gen=TypeMeta diff --git a/cmd/cloud-controller-manager/app/options/options_test.go b/cmd/cloud-controller-manager/app/options/options_test.go index b9825bb235..fce64bb959 100644 --- a/cmd/cloud-controller-manager/app/options/options_test.go +++ b/cmd/cloud-controller-manager/app/options/options_test.go @@ -24,11 +24,10 @@ import ( "github.com/spf13/pflag" - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/diff" - apiserverconfig "k8s.io/apiserver/pkg/apis/config" apiserveroptions "k8s.io/apiserver/pkg/server/options" + componentbaseconfig "k8s.io/component-base/config" cmoptions "k8s.io/kubernetes/cmd/controller-manager/app/options" ) @@ -40,13 +39,13 @@ func TestDefaultFlags(t *testing.T) { Port: DefaultInsecureCloudControllerManagerPort, // Note: InsecureServingOptions.ApplyTo will write the flag value back into the component config Address: "0.0.0.0", // Note: InsecureServingOptions.ApplyTo will write the flag value back into the component config MinResyncPeriod: metav1.Duration{Duration: 12 * time.Hour}, - ClientConnection: apimachineryconfig.ClientConnectionConfiguration{ + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ ContentType: "application/vnd.kubernetes.protobuf", QPS: 20.0, Burst: 30, }, ControllerStartInterval: metav1.Duration{Duration: 0}, - LeaderElection: apiserverconfig.LeaderElectionConfiguration{ + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ ResourceLock: "endpoints", LeaderElect: true, LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, @@ -158,13 +157,13 @@ func TestAddFlags(t *testing.T) { Port: DefaultInsecureCloudControllerManagerPort, // Note: InsecureServingOptions.ApplyTo will write the flag value back into the component config Address: "0.0.0.0", // Note: InsecureServingOptions.ApplyTo will write the flag value back into the component config MinResyncPeriod: metav1.Duration{Duration: 100 * time.Minute}, - ClientConnection: apimachineryconfig.ClientConnectionConfiguration{ + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ ContentType: "application/vnd.kubernetes.protobuf", QPS: 50.0, Burst: 100, }, ControllerStartInterval: metav1.Duration{Duration: 2 * time.Minute}, - LeaderElection: apiserverconfig.LeaderElectionConfiguration{ + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ ResourceLock: "configmap", LeaderElect: false, LeaseDuration: metav1.Duration{Duration: 30 * time.Second}, diff --git a/cmd/controller-manager/app/options/debugging.go b/cmd/controller-manager/app/options/debugging.go index e459b6d452..10271eabd2 100644 --- a/cmd/controller-manager/app/options/debugging.go +++ b/cmd/controller-manager/app/options/debugging.go @@ -19,7 +19,7 @@ package options import ( "github.com/spf13/pflag" - apiserverconfig "k8s.io/apiserver/pkg/apis/config" + componentbaseconfig "k8s.io/component-base/config" ) // DebuggingOptions holds the Debugging options. @@ -41,7 +41,7 @@ func (o *DebuggingOptions) AddFlags(fs *pflag.FlagSet) { } // ApplyTo fills up Debugging config with options. -func (o *DebuggingOptions) ApplyTo(cfg *apiserverconfig.DebuggingConfiguration) error { +func (o *DebuggingOptions) ApplyTo(cfg *componentbaseconfig.DebuggingConfiguration) error { if o == nil { return nil } diff --git a/cmd/controller-manager/app/options/generic.go b/cmd/controller-manager/app/options/generic.go index 3056038f40..2089c7179f 100644 --- a/cmd/controller-manager/app/options/generic.go +++ b/cmd/controller-manager/app/options/generic.go @@ -20,11 +20,10 @@ import ( "fmt" "strings" - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" - apiserverconfig "k8s.io/apiserver/pkg/apis/config" apiserverflag "k8s.io/apiserver/pkg/util/flag" + componentbaseconfig "k8s.io/component-base/config" "k8s.io/kubernetes/pkg/client/leaderelectionconfig" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" ) @@ -34,9 +33,9 @@ type GenericControllerManagerConfigurationOptions struct { Port int32 Address string MinResyncPeriod metav1.Duration - ClientConnection apimachineryconfig.ClientConnectionConfiguration + ClientConnection componentbaseconfig.ClientConnectionConfiguration ControllerStartInterval metav1.Duration - LeaderElection apiserverconfig.LeaderElectionConfiguration + LeaderElection componentbaseconfig.LeaderElectionConfiguration Debugging *DebuggingOptions Controllers []string } diff --git a/cmd/controller-manager/app/serve.go b/cmd/controller-manager/app/serve.go index 37fd22199d..c0e507b7ac 100644 --- a/cmd/controller-manager/app/serve.go +++ b/cmd/controller-manager/app/serve.go @@ -21,7 +21,6 @@ import ( "net/http" goruntime "runtime" - apiserverconfig "k8s.io/apiserver/pkg/apis/config" genericapifilters "k8s.io/apiserver/pkg/endpoints/filters" apirequest "k8s.io/apiserver/pkg/endpoints/request" apiserver "k8s.io/apiserver/pkg/server" @@ -29,6 +28,7 @@ import ( "k8s.io/apiserver/pkg/server/healthz" "k8s.io/apiserver/pkg/server/mux" "k8s.io/apiserver/pkg/server/routes" + componentbaseconfig "k8s.io/component-base/config" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/util/configz" ) @@ -52,7 +52,7 @@ func BuildHandlerChain(apiHandler http.Handler, authorizationInfo *apiserver.Aut } // NewBaseHandler takes in CompletedConfig and returns a handler. -func NewBaseHandler(c *apiserverconfig.DebuggingConfiguration, checks ...healthz.HealthzChecker) *mux.PathRecorderMux { +func NewBaseHandler(c *componentbaseconfig.DebuggingConfiguration, checks ...healthz.HealthzChecker) *mux.PathRecorderMux { mux := mux.NewPathRecorderMux("controller-manager") healthz.InstallHandler(mux, checks...) if c.EnableProfiling { diff --git a/cmd/kube-controller-manager/app/options/options_test.go b/cmd/kube-controller-manager/app/options/options_test.go index 4129038be7..f47431ec0e 100644 --- a/cmd/kube-controller-manager/app/options/options_test.go +++ b/cmd/kube-controller-manager/app/options/options_test.go @@ -25,11 +25,10 @@ import ( "github.com/spf13/pflag" - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/diff" - apiserverconfig "k8s.io/apiserver/pkg/apis/config" apiserveroptions "k8s.io/apiserver/pkg/server/options" + componentbaseconfig "k8s.io/component-base/config" cmoptions "k8s.io/kubernetes/cmd/controller-manager/app/options" kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" ) @@ -128,13 +127,13 @@ func TestAddFlags(t *testing.T) { Port: 10252, // Note: InsecureServingOptions.ApplyTo will write the flag value back into the component config Address: "0.0.0.0", // Note: InsecureServingOptions.ApplyTo will write the flag value back into the component config MinResyncPeriod: metav1.Duration{Duration: 8 * time.Hour}, - ClientConnection: apimachineryconfig.ClientConnectionConfiguration{ + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ ContentType: "application/json", QPS: 50.0, Burst: 100, }, ControllerStartInterval: metav1.Duration{Duration: 2 * time.Minute}, - LeaderElection: apiserverconfig.LeaderElectionConfiguration{ + LeaderElection: componentbaseconfig.LeaderElectionConfiguration{ ResourceLock: "configmap", LeaderElect: false, LeaseDuration: metav1.Duration{Duration: 30 * time.Second}, diff --git a/cmd/kube-proxy/app/server.go b/cmd/kube-proxy/app/server.go index f0edc12c75..17872f63c9 100644 --- a/cmd/kube-proxy/app/server.go +++ b/cmd/kube-proxy/app/server.go @@ -28,8 +28,7 @@ import ( "strings" "time" - "k8s.io/api/core/v1" - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" + v1 "k8s.io/api/core/v1" v1meta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" @@ -48,6 +47,7 @@ import ( "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" "k8s.io/client-go/tools/record" + componentbaseconfig "k8s.io/component-base/config" "k8s.io/kube-proxy/config/v1alpha1" api "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/kubelet/qos" @@ -422,7 +422,7 @@ type ProxyServer struct { // createClients creates a kube client and an event client from the given config and masterOverride. // TODO remove masterOverride when CLI flags are removed. -func createClients(config apimachineryconfig.ClientConnectionConfiguration, masterOverride string) (clientset.Interface, v1core.EventsGetter, error) { +func createClients(config componentbaseconfig.ClientConnectionConfiguration, masterOverride string) (clientset.Interface, v1core.EventsGetter, error) { var kubeConfig *rest.Config var err error diff --git a/cmd/kube-proxy/app/server_test.go b/cmd/kube-proxy/app/server_test.go index 7eee58376b..b45066f86f 100644 --- a/cmd/kube-proxy/app/server_test.go +++ b/cmd/kube-proxy/app/server_test.go @@ -26,9 +26,9 @@ import ( "github.com/stretchr/testify/assert" - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/diff" + componentbaseconfig "k8s.io/component-base/config" api "k8s.io/kubernetes/pkg/apis/core" kubeproxyconfig "k8s.io/kubernetes/pkg/proxy/apis/config" "k8s.io/kubernetes/pkg/util/configz" @@ -289,7 +289,7 @@ nodePortAddresses: } expected := &kubeproxyconfig.KubeProxyConfiguration{ BindAddress: expBindAddr, - ClientConnection: apimachineryconfig.ClientConnectionConfiguration{ + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ AcceptContentTypes: "abc", Burst: 100, ContentType: "content-type", diff --git a/cmd/kube-scheduler/app/options/options.go b/cmd/kube-scheduler/app/options/options.go index 972a6b7f09..4db4502d7b 100644 --- a/cmd/kube-scheduler/app/options/options.go +++ b/cmd/kube-scheduler/app/options/options.go @@ -24,7 +24,6 @@ import ( "time" corev1 "k8s.io/api/core/v1" - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/uuid" apiserveroptions "k8s.io/apiserver/pkg/server/options" @@ -39,6 +38,7 @@ import ( "k8s.io/client-go/tools/leaderelection" "k8s.io/client-go/tools/leaderelection/resourcelock" "k8s.io/client-go/tools/record" + componentbaseconfig "k8s.io/component-base/config" "k8s.io/klog" kubeschedulerconfigv1alpha1 "k8s.io/kube-scheduler/config/v1alpha1" schedulerappconfig "k8s.io/kubernetes/cmd/kube-scheduler/app/config" @@ -294,7 +294,7 @@ func makeLeaderElectionConfig(config kubeschedulerconfig.KubeSchedulerLeaderElec // createClients creates a kube client and an event client from the given config and masterOverride. // TODO remove masterOverride when CLI flags are removed. -func createClients(config apimachineryconfig.ClientConnectionConfiguration, masterOverride string, timeout time.Duration) (clientset.Interface, clientset.Interface, v1core.EventsGetter, error) { +func createClients(config componentbaseconfig.ClientConnectionConfiguration, masterOverride string, timeout time.Duration) (clientset.Interface, clientset.Interface, v1core.EventsGetter, error) { if len(config.Kubeconfig) == 0 && len(masterOverride) == 0 { klog.Warningf("Neither --kubeconfig nor --master was specified. Using default API client. This might not work.") } diff --git a/cmd/kube-scheduler/app/options/options_test.go b/cmd/kube-scheduler/app/options/options_test.go index b20fb0b0f8..730b5e7b41 100644 --- a/cmd/kube-scheduler/app/options/options_test.go +++ b/cmd/kube-scheduler/app/options/options_test.go @@ -28,11 +28,10 @@ import ( "testing" "time" - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/diff" - apiserverconfig "k8s.io/apiserver/pkg/apis/config" apiserveroptions "k8s.io/apiserver/pkg/server/options" + componentbaseconfig "k8s.io/component-base/config" kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config" ) @@ -209,7 +208,7 @@ users: MetricsBindAddress: "0.0.0.0:10251", FailureDomains: "kubernetes.io/hostname,failure-domain.beta.kubernetes.io/zone,failure-domain.beta.kubernetes.io/region", LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: apiserverconfig.LeaderElectionConfiguration{ + LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: true, LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, @@ -219,7 +218,7 @@ users: LockObjectNamespace: "kube-system", LockObjectName: "kube-scheduler", }, - ClientConnection: apimachineryconfig.ClientConnectionConfiguration{ + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ Kubeconfig: configKubeconfig, QPS: 50, Burst: 100, @@ -289,7 +288,7 @@ users: MetricsBindAddress: "", // defaults empty when not running from config file FailureDomains: "kubernetes.io/hostname,failure-domain.beta.kubernetes.io/zone,failure-domain.beta.kubernetes.io/region", LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{ - LeaderElectionConfiguration: apiserverconfig.LeaderElectionConfiguration{ + LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ LeaderElect: true, LeaseDuration: metav1.Duration{Duration: 15 * time.Second}, RenewDeadline: metav1.Duration{Duration: 10 * time.Second}, @@ -299,7 +298,7 @@ users: LockObjectNamespace: "kube-system", LockObjectName: "kube-scheduler", }, - ClientConnection: apimachineryconfig.ClientConnectionConfiguration{ + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ Kubeconfig: flagKubeconfig, QPS: 50, Burst: 100, diff --git a/pkg/client/leaderelectionconfig/config.go b/pkg/client/leaderelectionconfig/config.go index cc9ae7efac..7be3d5aa59 100644 --- a/pkg/client/leaderelectionconfig/config.go +++ b/pkg/client/leaderelectionconfig/config.go @@ -20,16 +20,17 @@ import ( "time" "github.com/spf13/pflag" - apiserverconfig "k8s.io/apiserver/pkg/apis/config" + componentbaseconfig "k8s.io/component-base/config" ) const ( // DefaultLeaseDuration defines a default duration of lease. + // TODO: This constant should move to the k8s.io/component-base/config package DefaultLeaseDuration = 15 * time.Second ) // BindFlags binds the LeaderElectionConfiguration struct fields to a flagset -func BindFlags(l *apiserverconfig.LeaderElectionConfiguration, fs *pflag.FlagSet) { +func BindFlags(l *componentbaseconfig.LeaderElectionConfiguration, fs *pflag.FlagSet) { fs.BoolVar(&l.LeaderElect, "leader-elect", l.LeaderElect, ""+ "Start a leader election client and gain leadership before "+ "executing the main loop. Enable this when running replicated "+ diff --git a/pkg/controller/apis/config/types.go b/pkg/controller/apis/config/types.go index c04a1b3552..c7a3190ddf 100644 --- a/pkg/controller/apis/config/types.go +++ b/pkg/controller/apis/config/types.go @@ -17,9 +17,8 @@ limitations under the License. package config import ( - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - apiserverconfig "k8s.io/apiserver/pkg/apis/config" + componentbaseconfig "k8s.io/component-base/config" ) // GroupResource describes an group resource. @@ -112,11 +111,11 @@ type GenericControllerManagerConfiguration struct { MinResyncPeriod metav1.Duration // ClientConnection specifies the kubeconfig file and client connection // settings for the proxy server to use when communicating with the apiserver. - ClientConnection apimachineryconfig.ClientConnectionConfiguration + ClientConnection componentbaseconfig.ClientConnectionConfiguration // How long to wait between starting controller managers ControllerStartInterval metav1.Duration // leaderElection defines the configuration of leader election client. - LeaderElection apiserverconfig.LeaderElectionConfiguration + LeaderElection componentbaseconfig.LeaderElectionConfiguration // Controllers is the list of controllers to enable or disable // '*' means "all enabled by default controllers" // 'foo' means "enable 'foo'" @@ -124,7 +123,7 @@ type GenericControllerManagerConfiguration struct { // first item for a particular name wins Controllers []string // DebuggingConfiguration holds configuration for Debugging related features. - Debugging apiserverconfig.DebuggingConfiguration + Debugging componentbaseconfig.DebuggingConfiguration } // KubeCloudSharedConfiguration contains elements shared by both kube-controller manager diff --git a/pkg/controller/apis/config/v1alpha1/defaults.go b/pkg/controller/apis/config/v1alpha1/defaults.go index af96572566..ccefd0a955 100644 --- a/pkg/controller/apis/config/v1alpha1/defaults.go +++ b/pkg/controller/apis/config/v1alpha1/defaults.go @@ -19,10 +19,9 @@ package v1alpha1 import ( "time" - apimachineryconfigv1alpha1 "k8s.io/apimachinery/pkg/apis/config/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kruntime "k8s.io/apimachinery/pkg/runtime" - apiserverconfigv1alpha1 "k8s.io/apiserver/pkg/apis/config/v1alpha1" + componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1" kubectrlmgrconfigv1alpha1 "k8s.io/kube-controller-manager/config/v1alpha1" utilpointer "k8s.io/utils/pointer" ) @@ -52,7 +51,7 @@ func SetDefaults_KubeControllerManagerConfiguration(obj *kubectrlmgrconfigv1alph obj.TTLAfterFinishedController.ConcurrentTTLSyncs = 5 } - // These defaults override the recommended defaults from the apimachineryconfigv1alpha1 package that are applied automatically + // These defaults override the recommended defaults from the componentbaseconfigv1alpha1 package that are applied automatically // These client-connection defaults are specific to the kube-controller-manager if obj.Generic.ClientConnection.QPS == 0.0 { obj.Generic.ClientConnection.QPS = 20.0 @@ -81,8 +80,8 @@ func RecommendedDefaultGenericControllerManagerConfiguration(obj *kubectrlmgrcon } // Use the default ClientConnectionConfiguration and LeaderElectionConfiguration options - apimachineryconfigv1alpha1.RecommendedDefaultClientConnectionConfiguration(&obj.ClientConnection) - apiserverconfigv1alpha1.RecommendedDefaultLeaderElectionConfiguration(&obj.LeaderElection) + componentbaseconfigv1alpha1.RecommendedDefaultClientConnectionConfiguration(&obj.ClientConnection) + componentbaseconfigv1alpha1.RecommendedDefaultLeaderElectionConfiguration(&obj.LeaderElection) } func SetDefaults_KubeCloudSharedConfiguration(obj *kubectrlmgrconfigv1alpha1.KubeCloudSharedConfiguration) { diff --git a/pkg/proxy/apis/config/types.go b/pkg/proxy/apis/config/types.go index dacee32bb3..2c79debd69 100644 --- a/pkg/proxy/apis/config/types.go +++ b/pkg/proxy/apis/config/types.go @@ -21,8 +21,8 @@ import ( "sort" "strings" - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + componentbaseconfig "k8s.io/component-base/config" ) // KubeProxyIPTablesConfiguration contains iptables-related configuration @@ -108,7 +108,7 @@ type KubeProxyConfiguration struct { HostnameOverride string // clientConnection specifies the kubeconfig file and client connection settings for the proxy // server to use when communicating with the apiserver. - ClientConnection apimachineryconfig.ClientConnectionConfiguration + ClientConnection componentbaseconfig.ClientConnectionConfiguration // iptables contains iptables-related configuration options. IPTables KubeProxyIPTablesConfiguration // ipvs contains ipvs-related configuration options. diff --git a/pkg/proxy/apis/config/validation/validation.go b/pkg/proxy/apis/config/validation/validation.go index 04d9e5ed9e..2637196530 100644 --- a/pkg/proxy/apis/config/validation/validation.go +++ b/pkg/proxy/apis/config/validation/validation.go @@ -23,10 +23,10 @@ import ( "strconv" "strings" - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" utilnet "k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/validation/field" + componentbaseconfig "k8s.io/component-base/config" apivalidation "k8s.io/kubernetes/pkg/apis/core/validation" kubeproxyconfig "k8s.io/kubernetes/pkg/proxy/apis/config" ) @@ -187,7 +187,7 @@ func validateProxyModeWindows(mode kubeproxyconfig.ProxyMode, fldPath *field.Pat return field.ErrorList{field.Invalid(fldPath.Child("ProxyMode"), string(mode), errMsg)} } -func validateClientConnectionConfiguration(config apimachineryconfig.ClientConnectionConfiguration, fldPath *field.Path) field.ErrorList { +func validateClientConnectionConfiguration(config componentbaseconfig.ClientConnectionConfiguration, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(config.Burst), fldPath.Child("Burst"))...) return allErrs diff --git a/pkg/proxy/apis/config/validation/validation_test.go b/pkg/proxy/apis/config/validation/validation_test.go index 9a054683d4..a241142329 100644 --- a/pkg/proxy/apis/config/validation/validation_test.go +++ b/pkg/proxy/apis/config/validation/validation_test.go @@ -23,9 +23,9 @@ import ( "testing" "time" - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/validation/field" + componentbaseconfig "k8s.io/component-base/config" kubeproxyconfig "k8s.io/kubernetes/pkg/proxy/apis/config" "k8s.io/utils/pointer" ) @@ -575,7 +575,7 @@ func TestValidateProxyMode(t *testing.T) { func TestValidateClientConnectionConfiguration(t *testing.T) { newPath := field.NewPath("KubeProxyConfiguration") - successCases := []apimachineryconfig.ClientConnectionConfiguration{ + successCases := []componentbaseconfig.ClientConnectionConfiguration{ { Burst: 0, }, @@ -591,11 +591,11 @@ func TestValidateClientConnectionConfiguration(t *testing.T) { } errorCases := []struct { - ccc apimachineryconfig.ClientConnectionConfiguration + ccc componentbaseconfig.ClientConnectionConfiguration msg string }{ { - ccc: apimachineryconfig.ClientConnectionConfiguration{Burst: -5}, + ccc: componentbaseconfig.ClientConnectionConfiguration{Burst: -5}, msg: "must be greater than or equal to 0", }, } diff --git a/pkg/scheduler/apis/config/types.go b/pkg/scheduler/apis/config/types.go index b0d36cd31b..f855b7c34a 100644 --- a/pkg/scheduler/apis/config/types.go +++ b/pkg/scheduler/apis/config/types.go @@ -17,9 +17,8 @@ limitations under the License. package config import ( - apimachineryconfig "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - apiserverconfig "k8s.io/apiserver/pkg/apis/config" + componentbaseconfig "k8s.io/component-base/config" ) const ( @@ -58,7 +57,7 @@ type KubeSchedulerConfiguration struct { // ClientConnection specifies the kubeconfig file and client connection // settings for the proxy server to use when communicating with the apiserver. - ClientConnection apimachineryconfig.ClientConnectionConfiguration + ClientConnection componentbaseconfig.ClientConnectionConfiguration // HealthzBindAddress is the IP address and port for the health check server to serve on, // defaulting to 0.0.0.0:10251 HealthzBindAddress string @@ -67,8 +66,8 @@ type KubeSchedulerConfiguration struct { MetricsBindAddress string // DebuggingConfiguration holds configuration for Debugging related features - // TODO: We might wanna make this a substruct like Debugging apiserverconfig.DebuggingConfiguration - apiserverconfig.DebuggingConfiguration + // TODO: We might wanna make this a substruct like Debugging componentbaseconfig.DebuggingConfiguration + componentbaseconfig.DebuggingConfiguration // DisablePreemption disables the pod preemption feature. DisablePreemption bool @@ -130,7 +129,7 @@ type SchedulerPolicyConfigMapSource struct { // KubeSchedulerLeaderElectionConfiguration expands LeaderElectionConfiguration // to include scheduler specific configuration. type KubeSchedulerLeaderElectionConfiguration struct { - apiserverconfig.LeaderElectionConfiguration + componentbaseconfig.LeaderElectionConfiguration // LockObjectNamespace defines the namespace of the lock object LockObjectNamespace string // LockObjectName defines the lock object name diff --git a/pkg/scheduler/apis/config/v1alpha1/defaults.go b/pkg/scheduler/apis/config/v1alpha1/defaults.go index 5768d2334b..f6a08af34a 100644 --- a/pkg/scheduler/apis/config/v1alpha1/defaults.go +++ b/pkg/scheduler/apis/config/v1alpha1/defaults.go @@ -21,7 +21,7 @@ import ( "strconv" "k8s.io/apimachinery/pkg/runtime" - apiserverconfigv1alpha1 "k8s.io/apiserver/pkg/apis/config/v1alpha1" + componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1" kubescedulerconfigv1alpha1 "k8s.io/kube-scheduler/config/v1alpha1" // this package shouldn't really depend on other k8s.io/kubernetes code @@ -97,7 +97,7 @@ func SetDefaults_KubeSchedulerConfiguration(obj *kubescedulerconfigv1alpha1.Kube } // Use the default LeaderElectionConfiguration options - apiserverconfigv1alpha1.RecommendedDefaultLeaderElectionConfiguration(&obj.LeaderElection.LeaderElectionConfiguration) + componentbaseconfigv1alpha1.RecommendedDefaultLeaderElectionConfiguration(&obj.LeaderElection.LeaderElectionConfiguration) if obj.BindTimeoutSeconds == nil { defaultBindTimeoutSeconds := int64(600) diff --git a/pkg/scheduler/apis/config/validation/validation.go b/pkg/scheduler/apis/config/validation/validation.go index 00fff14b43..0d44db9cd8 100644 --- a/pkg/scheduler/apis/config/validation/validation.go +++ b/pkg/scheduler/apis/config/validation/validation.go @@ -17,17 +17,16 @@ limitations under the License. package validation import ( - apimachinery "k8s.io/apimachinery/pkg/apis/config/validation" "k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation/field" - apiserver "k8s.io/apiserver/pkg/apis/config/validation" + componentbasevalidation "k8s.io/component-base/config/validation" "k8s.io/kubernetes/pkg/scheduler/apis/config" ) // ValidateKubeSchedulerConfiguration ensures validation of the KubeSchedulerConfiguration struct func ValidateKubeSchedulerConfiguration(cc *config.KubeSchedulerConfiguration) field.ErrorList { allErrs := field.ErrorList{} - allErrs = append(allErrs, apimachinery.ValidateClientConnectionConfiguration(&cc.ClientConnection, field.NewPath("clientConnection"))...) + allErrs = append(allErrs, componentbasevalidation.ValidateClientConnectionConfiguration(&cc.ClientConnection, field.NewPath("clientConnection"))...) allErrs = append(allErrs, ValidateKubeSchedulerLeaderElectionConfiguration(&cc.LeaderElection, field.NewPath("leaderElection"))...) if len(cc.SchedulerName) == 0 { allErrs = append(allErrs, field.Required(field.NewPath("schedulerName"), "")) @@ -57,7 +56,7 @@ func ValidateKubeSchedulerLeaderElectionConfiguration(cc *config.KubeSchedulerLe if !cc.LeaderElectionConfiguration.LeaderElect { return allErrs } - allErrs = append(allErrs, apiserver.ValidateLeaderElectionConfiguration(&cc.LeaderElectionConfiguration, field.NewPath("leaderElectionConfiguration"))...) + allErrs = append(allErrs, componentbasevalidation.ValidateLeaderElectionConfiguration(&cc.LeaderElectionConfiguration, field.NewPath("leaderElectionConfiguration"))...) if len(cc.LockObjectNamespace) == 0 { allErrs = append(allErrs, field.Required(fldPath.Child("lockObjectNamespace"), "")) } diff --git a/pkg/scheduler/apis/config/validation/validation_test.go b/pkg/scheduler/apis/config/validation/validation_test.go index 76ca5b4601..4213a1e9eb 100644 --- a/pkg/scheduler/apis/config/validation/validation_test.go +++ b/pkg/scheduler/apis/config/validation/validation_test.go @@ -20,9 +20,8 @@ import ( "testing" "time" - apimachinery "k8s.io/apimachinery/pkg/apis/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - apiserver "k8s.io/apiserver/pkg/apis/config" + componentbaseconfig "k8s.io/component-base/config" "k8s.io/kubernetes/pkg/scheduler/apis/config" ) @@ -33,7 +32,7 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) { HealthzBindAddress: "0.0.0.0:10254", MetricsBindAddress: "0.0.0.0:10254", HardPodAffinitySymmetricWeight: 80, - ClientConnection: apimachinery.ClientConnectionConfiguration{ + ClientConnection: componentbaseconfig.ClientConnectionConfiguration{ AcceptContentTypes: "application/json", ContentType: "application/json", QPS: 10, @@ -50,7 +49,7 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) { LeaderElection: config.KubeSchedulerLeaderElectionConfiguration{ LockObjectNamespace: "name", LockObjectName: "name", - LeaderElectionConfiguration: apiserver.LeaderElectionConfiguration{ + LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{ ResourceLock: "configmap", LeaderElect: true, LeaseDuration: metav1.Duration{Duration: 30 * time.Second}, diff --git a/staging/src/k8s.io/kube-controller-manager/config/v1alpha1/types.go b/staging/src/k8s.io/kube-controller-manager/config/v1alpha1/types.go index 2e9f45b5b4..38d8bf4d3b 100644 --- a/staging/src/k8s.io/kube-controller-manager/config/v1alpha1/types.go +++ b/staging/src/k8s.io/kube-controller-manager/config/v1alpha1/types.go @@ -17,9 +17,8 @@ limitations under the License. package v1alpha1 import ( - apimachineryconfigv1alpha1 "k8s.io/apimachinery/pkg/apis/config/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - apiserverconfigv1alpha1 "k8s.io/apiserver/pkg/apis/config/v1alpha1" + componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1" ) // PersistentVolumeRecyclerConfiguration contains elements describing persistent volume plugins. @@ -161,11 +160,11 @@ type GenericControllerManagerConfiguration struct { MinResyncPeriod metav1.Duration // ClientConnection specifies the kubeconfig file and client connection // settings for the proxy server to use when communicating with the apiserver. - ClientConnection apimachineryconfigv1alpha1.ClientConnectionConfiguration + ClientConnection componentbaseconfigv1alpha1.ClientConnectionConfiguration // How long to wait between starting controller managers ControllerStartInterval metav1.Duration // leaderElection defines the configuration of leader election client. - LeaderElection apiserverconfigv1alpha1.LeaderElectionConfiguration + LeaderElection componentbaseconfigv1alpha1.LeaderElectionConfiguration // Controllers is the list of controllers to enable or disable // '*' means "all enabled by default controllers" // 'foo' means "enable 'foo'" @@ -173,7 +172,7 @@ type GenericControllerManagerConfiguration struct { // first item for a particular name wins Controllers []string // DebuggingConfiguration holds configuration for Debugging related features. - Debugging apiserverconfigv1alpha1.DebuggingConfiguration + Debugging componentbaseconfigv1alpha1.DebuggingConfiguration } // KubeCloudSharedConfiguration contains elements shared by both kube-controller manager diff --git a/staging/src/k8s.io/kube-proxy/config/v1alpha1/types.go b/staging/src/k8s.io/kube-proxy/config/v1alpha1/types.go index b9c370b0d3..ecf95d68d2 100644 --- a/staging/src/k8s.io/kube-proxy/config/v1alpha1/types.go +++ b/staging/src/k8s.io/kube-proxy/config/v1alpha1/types.go @@ -17,8 +17,8 @@ limitations under the License. package v1alpha1 import ( - apimachineryconfigv1alpha1 "k8s.io/apimachinery/pkg/apis/config/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1" ) // KubeProxyIPTablesConfiguration contains iptables-related configuration @@ -104,7 +104,7 @@ type KubeProxyConfiguration struct { HostnameOverride string `json:"hostnameOverride"` // clientConnection specifies the kubeconfig file and client connection settings for the proxy // server to use when communicating with the apiserver. - ClientConnection apimachineryconfigv1alpha1.ClientConnectionConfiguration `json:"clientConnection"` + ClientConnection componentbaseconfigv1alpha1.ClientConnectionConfiguration `json:"clientConnection"` // iptables contains iptables-related configuration options. IPTables KubeProxyIPTablesConfiguration `json:"iptables"` // ipvs contains ipvs-related configuration options. diff --git a/staging/src/k8s.io/kube-scheduler/config/v1alpha1/types.go b/staging/src/k8s.io/kube-scheduler/config/v1alpha1/types.go index 6bdb5500d6..e37649ad24 100644 --- a/staging/src/k8s.io/kube-scheduler/config/v1alpha1/types.go +++ b/staging/src/k8s.io/kube-scheduler/config/v1alpha1/types.go @@ -17,9 +17,8 @@ limitations under the License. package v1alpha1 import ( - apimachineryconfigv1alpha1 "k8s.io/apimachinery/pkg/apis/config/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - apiserverconfigv1alpha1 "k8s.io/apiserver/pkg/apis/config/v1alpha1" + componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1" ) const ( @@ -54,7 +53,7 @@ type KubeSchedulerConfiguration struct { // ClientConnection specifies the kubeconfig file and client connection // settings for the proxy server to use when communicating with the apiserver. - ClientConnection apimachineryconfigv1alpha1.ClientConnectionConfiguration `json:"clientConnection"` + ClientConnection componentbaseconfigv1alpha1.ClientConnectionConfiguration `json:"clientConnection"` // HealthzBindAddress is the IP address and port for the health check server to serve on, // defaulting to 0.0.0.0:10251 HealthzBindAddress string `json:"healthzBindAddress"` @@ -63,8 +62,8 @@ type KubeSchedulerConfiguration struct { MetricsBindAddress string `json:"metricsBindAddress"` // DebuggingConfiguration holds configuration for Debugging related features - // TODO: We might wanna make this a substruct like Debugging apiserverconfig.DebuggingConfiguration - apiserverconfigv1alpha1.DebuggingConfiguration `json:",inline"` + // TODO: We might wanna make this a substruct like Debugging componentbaseconfigv1alpha1.DebuggingConfiguration + componentbaseconfigv1alpha1.DebuggingConfiguration `json:",inline"` // DisablePreemption disables the pod preemption feature. DisablePreemption bool `json:"disablePreemption"` @@ -126,7 +125,7 @@ type SchedulerPolicyConfigMapSource struct { // KubeSchedulerLeaderElectionConfiguration expands LeaderElectionConfiguration // to include scheduler specific configuration. type KubeSchedulerLeaderElectionConfiguration struct { - apiserverconfigv1alpha1.LeaderElectionConfiguration `json:",inline"` + componentbaseconfigv1alpha1.LeaderElectionConfiguration `json:",inline"` // LockObjectNamespace defines the namespace of the lock object LockObjectNamespace string `json:"lockObjectNamespace"` // LockObjectName defines the lock object name