From a9853d067ebc0222128fdd3afc795096b6d2ba78 Mon Sep 17 00:00:00 2001 From: whitewindmills Date: Thu, 11 Jul 2024 11:29:36 +0800 Subject: [PATCH] Add missing command line arguments for karmada-operator Signed-off-by: whitewindmills --- operator/cmd/operator/app/operator.go | 4 +--- operator/cmd/operator/app/options/options.go | 13 ++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/operator/cmd/operator/app/operator.go b/operator/cmd/operator/app/operator.go index b1fb746e8a75..871a043927a4 100644 --- a/operator/cmd/operator/app/operator.go +++ b/operator/cmd/operator/app/operator.go @@ -20,9 +20,7 @@ import ( "context" "flag" "fmt" - "net" "os" - "strconv" "github.com/spf13/cobra" "k8s.io/apimachinery/pkg/util/sets" @@ -174,7 +172,7 @@ func createControllerManager(ctx context.Context, o *options.Options) (controlle RenewDeadline: &o.LeaderElection.RenewDeadline.Duration, RetryPeriod: &o.LeaderElection.RetryPeriod.Duration, LeaderElectionResourceLock: o.LeaderElection.ResourceLock, - HealthProbeBindAddress: net.JoinHostPort(o.BindAddress, strconv.Itoa(o.SecurePort)), + HealthProbeBindAddress: o.HealthProbeBindAddress, LivenessEndpointName: "/healthz", Metrics: metricsserver.Options{BindAddress: o.MetricsBindAddress}, Controller: config.Controller{ diff --git a/operator/cmd/operator/app/options/options.go b/operator/cmd/operator/app/options/options.go index 64e11bf36a00..cc0fe53f1756 100644 --- a/operator/cmd/operator/app/options/options.go +++ b/operator/cmd/operator/app/options/options.go @@ -39,11 +39,6 @@ type Options struct { Controllers []string // LeaderElection defines the configuration of leader election client. LeaderElection componentbaseconfig.LeaderElectionConfiguration - // BindAddress is the IP address on which to listen for the --secure-port port. - BindAddress string - // SecurePort is the port that the the server serves at. - // Note: We hope support https in the future once controller-runtime provides the functionality. - SecurePort int // KubeAPIQPS is the QPS to use while talking with karmada-apiserver. KubeAPIQPS float32 // KubeAPIBurst is the burst to allow while talking with karmada-apiserver. @@ -56,6 +51,10 @@ type Options struct { // It can be set to "0" to disable the metrics serving. // Defaults to ":8080". MetricsBindAddress string + // HealthProbeBindAddress is the TCP address that the controller should bind to + // for serving health probes + // It can be set to "0" or "" to disable serving the health probe. + HealthProbeBindAddress string // ConcurrentKarmadaSyncs is the number of karmada objects that are allowed to sync concurrently. ConcurrentKarmadaSyncs int } @@ -73,8 +72,6 @@ func NewOptions() *Options { ResourceNamespace: "karmada-system", ResourceName: "karmada-operator", }, - BindAddress: "0.0.0.0", - SecurePort: 8443, KubeAPIQPS: 50, KubeAPIBurst: 100, ConcurrentKarmadaSyncs: 5, @@ -84,6 +81,8 @@ func NewOptions() *Options { // AddFlags adds flags to the specified FlagSet. func (o *Options) AddFlags(fs *pflag.FlagSet, allControllers []string, disabledByDefaultControllers []string) { + fs.StringVar(&o.MetricsBindAddress, "metrics-bind-address", ":8080", "The TCP address that the controller should bind to for serving prometheus metrics(e.g. 127.0.0.1:8080, :8080). It can be set to \"0\" to disable the metrics serving.") + fs.StringVar(&o.HealthProbeBindAddress, "health-probe-bind-address", ":8443", "The TCP address that the controller should bind to for serving health probes(e.g. 127.0.0.1:8443, :8443). It can be set to \"0\" or \"\" to disable serving the health probe.") fs.DurationVar(&o.ResyncPeriod.Duration, "resync-period", o.ResyncPeriod.Duration, "ResyncPeriod determines the minimum frequency at which watched resources are reconciled.") fs.Float32Var(&o.KubeAPIQPS, "kube-api-qps", o.KubeAPIQPS, "QPS to use while talking with kubernetes apiserver.") fs.Int32Var(&o.KubeAPIBurst, "kube-api-burst", o.KubeAPIBurst, "Burst to use while talking with kubernetes apiserver.")