From ff99c24205f399b6324192945a1871ac196320d3 Mon Sep 17 00:00:00 2001 From: qclc <39878907+qclc@users.noreply.github.com> Date: Wed, 8 Dec 2021 16:39:41 +0800 Subject: [PATCH] remove "k8s.io/kubernetes/pkg/controller/apis/config" dependency for yurt-controller-manager (#664) --- .../app/options/generic.go | 2 +- .../app/options/options.go | 2 +- pkg/controller/apis/config/types.go | 3 +- .../controller/apis/config/types.go | 49 +++++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 pkg/controller/kubernetes/controller/apis/config/types.go diff --git a/cmd/yurt-controller-manager/app/options/generic.go b/cmd/yurt-controller-manager/app/options/generic.go index 1958b149cbc..51701de47ce 100644 --- a/cmd/yurt-controller-manager/app/options/generic.go +++ b/cmd/yurt-controller-manager/app/options/generic.go @@ -23,9 +23,9 @@ import ( "k8s.io/apimachinery/pkg/util/sets" cliflag "k8s.io/component-base/cli/flag" componentbaseconfig "k8s.io/component-base/config" - kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" "github.com/openyurtio/openyurt/pkg/controller/kubernetes/client/leaderelectionconfig" + kubectrlmgrconfig "github.com/openyurtio/openyurt/pkg/controller/kubernetes/controller/apis/config" ) // GenericControllerManagerConfigurationOptions holds the options which are generic. diff --git a/cmd/yurt-controller-manager/app/options/options.go b/cmd/yurt-controller-manager/app/options/options.go index acaee6a155d..ccf68b9c92b 100644 --- a/cmd/yurt-controller-manager/app/options/options.go +++ b/cmd/yurt-controller-manager/app/options/options.go @@ -37,10 +37,10 @@ import ( componentbaseconfig "k8s.io/component-base/config" "k8s.io/klog/v2" nodelifecycleconfig "k8s.io/kube-controller-manager/config/v1alpha1" - kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" utilpointer "k8s.io/utils/pointer" yurtcontrollerconfig "github.com/openyurtio/openyurt/cmd/yurt-controller-manager/app/config" + kubectrlmgrconfig "github.com/openyurtio/openyurt/pkg/controller/kubernetes/controller/apis/config" ) const ( diff --git a/pkg/controller/apis/config/types.go b/pkg/controller/apis/config/types.go index 1713485adb2..ad12bc01f9b 100644 --- a/pkg/controller/apis/config/types.go +++ b/pkg/controller/apis/config/types.go @@ -19,7 +19,8 @@ package config import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" nodelifecycleconfig "k8s.io/kube-controller-manager/config/v1alpha1" - kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" + + kubectrlmgrconfig "github.com/openyurtio/openyurt/pkg/controller/kubernetes/controller/apis/config" ) // YurtControllerManagerConfiguration contains elements describing yurt-controller manager. diff --git a/pkg/controller/kubernetes/controller/apis/config/types.go b/pkg/controller/kubernetes/controller/apis/config/types.go new file mode 100644 index 00000000000..fc7cccb671b --- /dev/null +++ b/pkg/controller/kubernetes/controller/apis/config/types.go @@ -0,0 +1,49 @@ +/* +Copyright 2018 The Kubernetes Authors. +Copyright 2021 The OpenYurt 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 config + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + componentbaseconfig "k8s.io/component-base/config" +) + +// GenericControllerManagerConfiguration holds configuration for a generic controller-manager +type GenericControllerManagerConfiguration struct { + // port is the port that the controller-manager's http service runs on. + Port int32 + // address is the IP address to serve on (set to 0.0.0.0 for all interfaces). + Address string + // minResyncPeriod is the resync period in reflectors; will be random between + // minResyncPeriod and 2*minResyncPeriod. + MinResyncPeriod metav1.Duration + // ClientConnection specifies the kubeconfig file and client connection + // settings for the proxy server to use when communicating with the apiserver. + ClientConnection componentbaseconfig.ClientConnectionConfiguration + // How long to wait between starting controller managers + ControllerStartInterval metav1.Duration + // leaderElection defines the configuration of leader election client. + LeaderElection componentbaseconfig.LeaderElectionConfiguration + // Controllers is the list of controllers to enable or disable + // '*' means "all enabled by default controllers" + // 'foo' means "enable 'foo'" + // '-foo' means "disable 'foo'" + // first item for a particular name wins + Controllers []string + // DebuggingConfiguration holds configuration for Debugging related features. + Debugging componentbaseconfig.DebuggingConfiguration +}