You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uniffle.apache.org by xi...@apache.org on 2023/03/05 12:12:27 UTC
[incubator-uniffle] branch master updated: [#645][Improvement] feat(operator): support manager parameter configuration (#670)
This is an automated email from the ASF dual-hosted git repository.
xianjin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git
The following commit(s) were added to refs/heads/master by this push:
new a6365cb8 [#645][Improvement] feat(operator): support manager parameter configuration (#670)
a6365cb8 is described below
commit a6365cb8d2fdeda078a687ea165b76c7f3e017a8
Author: Yu Zhao <96...@qq.com>
AuthorDate: Sun Mar 5 20:12:21 2023 +0800
[#645][Improvement] feat(operator): support manager parameter configuration (#670)
### What changes were proposed in this pull request?
Support Operator Manager parameter configuration.
### Why are the changes needed?
1. It is possible to customize parameters and modify the required configuration parameters.
2. Hope to make reasonable use of Kubernetes services.
Closes #645
### Does this PR introduce _any_ user-facing change?
Because in real-world scenarios, it may be necessary to adjust some parameters, such as Namespace.
### How was this patch tested?
Manually verified.
![image](https://user-images.githubusercontent.com/45311215/221807077-9b07f00d-e88e-4cea-894c-935f4096a1e7.png)
---
deploy/kubernetes/operator/cmd/controller/main.go | 5 +----
.../operator/pkg/controller/config/config.go | 25 ++++++++++++++++++++--
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/deploy/kubernetes/operator/cmd/controller/main.go b/deploy/kubernetes/operator/cmd/controller/main.go
index edebc133..357f6108 100644
--- a/deploy/kubernetes/operator/cmd/controller/main.go
+++ b/deploy/kubernetes/operator/cmd/controller/main.go
@@ -37,10 +37,7 @@ func main() {
klog.Infof("run config: %+v", cfg)
// create a manager for leader election.
- mgr, err := ctrl.NewManager(cfg.RESTConfig, ctrl.Options{
- LeaderElection: true,
- LeaderElectionID: cfg.LeaderElectionID(),
- })
+ mgr, err := ctrl.NewManager(cfg.RESTConfig, cfg.ManagerOptions)
if err != nil {
klog.Fatal(err)
}
diff --git a/deploy/kubernetes/operator/pkg/controller/config/config.go b/deploy/kubernetes/operator/pkg/controller/config/config.go
index 73f19f5a..3839fc16 100644
--- a/deploy/kubernetes/operator/pkg/controller/config/config.go
+++ b/deploy/kubernetes/operator/pkg/controller/config/config.go
@@ -19,18 +19,30 @@ package config
import (
"flag"
+ "time"
+
+ "k8s.io/utils/pointer"
+
+ ctrl "sigs.k8s.io/controller-runtime"
"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/constants"
"github.com/apache/incubator-uniffle/deploy/kubernetes/operator/pkg/utils"
)
const (
- flagWorkers = "workers"
+ flagWorkers = "workers"
+ managerLeaderElection = "leader-election"
+ managerLeaderElectionID = "leader-election-id"
+ managerLeaderElectionNamespace = "leader-election-namespace"
+ managerSyncPeriod = "sync-period"
+ managerRetryPeriod = "retry-period"
+ managerNamespace = "namespace"
)
// Config contains all configurations.
type Config struct {
- Workers int
+ Workers int
+ ManagerOptions ctrl.Options
utils.GenericConfig
}
@@ -41,7 +53,16 @@ func (c *Config) LeaderElectionID() string {
// AddFlags adds all configurations to the global flags.
func (c *Config) AddFlags() {
+ c.ManagerOptions.SyncPeriod = pointer.Duration(time.Hour * 10)
+ c.ManagerOptions.RetryPeriod = pointer.Duration(time.Second * 2)
flag.IntVar(&c.Workers, flagWorkers, 1, "Concurrency of the rss controller.")
+ flag.BoolVar(&c.ManagerOptions.LeaderElection, managerLeaderElection, true, "LeaderElection determines whether or not to use leader election when starting the manager.")
+ flag.StringVar(&c.ManagerOptions.LeaderElectionID, managerLeaderElectionID, c.LeaderElectionID(), "LeaderElectionID determines the name of the resource that leader election will use for holding the leader lock.")
+ flag.StringVar(&c.ManagerOptions.LeaderElectionNamespace, managerLeaderElectionNamespace, "kube-system", "LeaderElectionNamespace determines the namespace in which the leader election resource will be created.")
+ flag.StringVar(&c.ManagerOptions.Namespace, managerNamespace, "", "Namespace if specified restricts the manager's cache to watch objects in the desired namespace Defaults to all namespaces.")
+ flag.DurationVar(c.ManagerOptions.SyncPeriod, managerSyncPeriod, time.Hour*10, "SyncPeriod determines the minimum frequency at which watched resources are reconciled.")
+ flag.DurationVar(c.ManagerOptions.RetryPeriod, managerRetryPeriod, time.Second*2, "RetryPeriod is the duration the LeaderElector clients should wait between tries of actions.")
+
c.GenericConfig.AddFlags()
}