Skip to content

Commit

Permalink
Add missing command line arguments for karmada-operator
Browse files Browse the repository at this point in the history
Signed-off-by: whitewindmills <[email protected]>
  • Loading branch information
whitewindmills committed Jul 18, 2024
1 parent 71de3dc commit b12bcf4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 1 addition & 3 deletions operator/cmd/operator/app/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import (
"context"
"flag"
"fmt"
"net"
"os"
"strconv"

"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -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{
Expand Down
18 changes: 11 additions & 7 deletions operator/cmd/operator/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import (
"k8s.io/component-base/config/options"
)

const (
defaultBindAddress = "0.0.0.0"

Check failure on line 33 in operator/cmd/operator/app/options/options.go

View workflow job for this annotation

GitHub Actions / lint

const `defaultBindAddress` is unused (unused)
defaultPort = 8443

Check failure on line 34 in operator/cmd/operator/app/options/options.go

View workflow job for this annotation

GitHub Actions / lint

const `defaultPort` is unused (unused)
)

// Options is the main context object for the karmada-operator.
type Options struct {
// Controllers is the list of controllers to enable or disable
Expand All @@ -39,11 +44,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.
Expand All @@ -56,6 +56,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
}
Expand All @@ -73,8 +77,6 @@ func NewOptions() *Options {
ResourceNamespace: "karmada-system",
ResourceName: "karmada-operator",
},
BindAddress: "0.0.0.0",
SecurePort: 8443,
KubeAPIQPS: 50,
KubeAPIBurst: 100,
ConcurrentKarmadaSyncs: 5,
Expand All @@ -84,6 +86,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.")
Expand Down

0 comments on commit b12bcf4

Please sign in to comment.