Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dashboard: support multi-replicas election #784

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions cmd/dashboard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ var (
port uint16
devMode bool
staticDir string

leaderElection bool
leaderElectionNamespace string
leaderElectionLeaseDuration time.Duration
)

func main() {
Expand All @@ -77,6 +81,9 @@ func main() {
cmd.PersistentFlags().Uint16Var(&port, "port", 8088, "port to listen on")
cmd.PersistentFlags().BoolVar(&devMode, "dev", false, "enable dev mode")
cmd.PersistentFlags().StringVar(&staticDir, "static-dir", "", "static files to serve")
cmd.PersistentFlags().BoolVar(&leaderElection, "leader-election", false, "Enables leader election. If leader election is enabled, additional RBAC rules are required. ")
cmd.PersistentFlags().StringVar(&leaderElectionNamespace, "leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set.")
cmd.PersistentFlags().DurationVar(&leaderElectionLeaseDuration, "leader-election-lease-duration", 15*time.Second, "Duration, in seconds, that non-leader candidates will wait to force acquire leadership. Defaults to 15 seconds.")

goFlag := goflag.CommandLine
klog.InitFlags(goFlag)
Expand Down Expand Up @@ -186,10 +193,13 @@ func getLocalConfig() (*rest.Config, error) {

func newManager(conf *rest.Config) (ctrl.Manager, error) {
return ctrl.NewManager(conf, ctrl.Options{
Scheme: scheme,
Port: 9442,
MetricsBindAddress: "0.0.0.0:8082",
LeaderElectionID: "dashboard.juicefs.com",
Scheme: scheme,
Port: 9442,
MetricsBindAddress: "0.0.0.0:8082",
LeaderElection: leaderElection,
LeaderElectionID: "dashboard.juicefs.com",
LeaderElectionNamespace: leaderElectionNamespace,
LeaseDuration: &leaderElectionLeaseDuration,
NewCache: cache.BuilderWithOptions(cache.Options{
Scheme: scheme,
}),
Expand Down
Loading