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

✨LeaderElection configuration as flags #2664

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
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
29 changes: 22 additions & 7 deletions bootstrap/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ func init() {
}

var (
metricsAddr string
enableLeaderElection bool
watchNamespace string
profilerAddress string
kubeadmConfigConcurrency int
syncPeriod time.Duration
webhookPort int
metricsAddr string
enableLeaderElection bool
leaderElectionLeaseDuration time.Duration
leaderElectionRenewDeadline time.Duration
leaderElectionRetryPeriod time.Duration
watchNamespace string
profilerAddress string
kubeadmConfigConcurrency int
syncPeriod time.Duration
webhookPort int
)

func InitFlags(fs *pflag.FlagSet) {
Expand All @@ -75,6 +78,15 @@ func InitFlags(fs *pflag.FlagSet) {
fs.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")

fs.DurationVar(&leaderElectionLeaseDuration, "leader-election-lease-duration", 15*time.Second,
"Interval at which non-leader candidates will wait to force acquire leadership (duration string)")

fs.DurationVar(&leaderElectionRenewDeadline, "leader-election-renew-deadline", 10*time.Second,
"Duration that the acting master will retry refreshing leadership before giving up (duration string)")

fs.DurationVar(&leaderElectionRetryPeriod, "leader-election-retry-period", 2*time.Second,
"Duration the LeaderElector clients should wait between tries of actions (duration string)")

fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

Expand Down Expand Up @@ -115,6 +127,9 @@ func main() {
MetricsBindAddress: metricsAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "kubeadm-bootstrap-manager-leader-election-capi",
LeaseDuration: &leaderElectionLeaseDuration,
RenewDeadline: &leaderElectionRenewDeadline,
RetryPeriod: &leaderElectionRetryPeriod,
Namespace: watchNamespace,
SyncPeriod: &syncPeriod,
NewClient: newClientFunc,
Expand Down
15 changes: 15 additions & 0 deletions controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func init() {
var (
metricsAddr string
enableLeaderElection bool
leaderElectionLeaseDuration time.Duration
leaderElectionRenewDeadline time.Duration
leaderElectionRetryPeriod time.Duration
watchNamespace string
profilerAddress string
kubeadmControlPlaneConcurrency int
Expand All @@ -73,6 +76,15 @@ func InitFlags(fs *pflag.FlagSet) {
fs.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")

fs.DurationVar(&leaderElectionLeaseDuration, "leader-election-lease-duration", 15*time.Second,
"Interval at which non-leader candidates will wait to force acquire leadership (duration string)")

fs.DurationVar(&leaderElectionRenewDeadline, "leader-election-renew-deadline", 10*time.Second,
"Duration that the acting master will retry refreshing leadership before giving up (duration string)")

fs.DurationVar(&leaderElectionRetryPeriod, "leader-election-retry-period", 2*time.Second,
"Duration the LeaderElector clients should wait between tries of actions (duration string)")

fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

Expand Down Expand Up @@ -107,6 +119,9 @@ func main() {
MetricsBindAddress: metricsAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "kubeadm-control-plane-manager-leader-election-capi",
LeaseDuration: &leaderElectionLeaseDuration,
RenewDeadline: &leaderElectionRenewDeadline,
RetryPeriod: &leaderElectionRetryPeriod,
Namespace: watchNamespace,
SyncPeriod: &syncPeriod,
NewClient: newClientFunc,
Expand Down
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ var (
// flags
metricsAddr string
enableLeaderElection bool
leaderElectionLeaseDuration time.Duration
leaderElectionRenewDeadline time.Duration
leaderElectionRetryPeriod time.Duration
watchNamespace string
profilerAddress string
clusterConcurrency int
Expand Down Expand Up @@ -82,6 +85,15 @@ func InitFlags(fs *pflag.FlagSet) {
fs.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")

fs.DurationVar(&leaderElectionLeaseDuration, "leader-election-lease-duration", 15*time.Second,
"Interval at which non-leader candidates will wait to force acquire leadership (duration string)")

fs.DurationVar(&leaderElectionRenewDeadline, "leader-election-renew-deadline", 10*time.Second,
"Duration that the acting master will retry refreshing leadership before giving up (duration string)")

fs.DurationVar(&leaderElectionRetryPeriod, "leader-election-retry-period", 2*time.Second,
"Duration the LeaderElector clients should wait between tries of actions (duration string)")

fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

Expand Down Expand Up @@ -137,6 +149,9 @@ func main() {
MetricsBindAddress: metricsAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "controller-leader-election-capi",
LeaseDuration: &leaderElectionLeaseDuration,
RenewDeadline: &leaderElectionRenewDeadline,
RetryPeriod: &leaderElectionRetryPeriod,
Namespace: watchNamespace,
SyncPeriod: &syncPeriod,
NewClient: newClientFunc,
Expand Down
2 changes: 1 addition & 1 deletion third_party/kubernetes-drain/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
The code in this directory has been copied from:
github.com/kubernetes/kubectl/pkg/drain@846b394714fe1cb467fca0e259890b8ba2ec4544
github.com/kubernetes/kubectl/pkg/drain@a17d91f9f5b34c73bed0bfc75b70bd762b725231
1 change: 0 additions & 1 deletion third_party/kubernetes-drain/drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ func waitForDelete(params waitForDeleteParams) ([]corev1.Pod, error) {
default:
return false, nil
}
return false, nil
trutx marked this conversation as resolved.
Show resolved Hide resolved
}
return true, nil
})
Expand Down