Skip to content

Commit

Permalink
config agent leader election by klusterletconfig
Browse files Browse the repository at this point in the history
Signed-off-by: Qing Hao <[email protected]>
  • Loading branch information
haoqing0110 committed Nov 22, 2024
1 parent 68eb264 commit f72dbe6
Show file tree
Hide file tree
Showing 21 changed files with 499 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ spec:
ClusterAnnotations is annotations with the reserve prefix "agent.open-cluster-management.io" set on
ManagedCluster when creating only, other actors can update it afterwards.
type: object
disableLeaderElection:
description: |-
Disable leader election.
Use the klusterlet agent default value if this field is not defined.
type: boolean
featureGates:
description: "FeatureGates represents the list of feature gates
for registration\nIf it is set empty, default feature gates
Expand Down Expand Up @@ -289,6 +294,31 @@ spec:
If it is set empty, use the default value: 50
format: int32
type: integer
leaderElectionLeaseDuration:
description: |-
The duration that non-leader candidates will wait after observing a leadership
renewal until attempting to acquire leadership of a led but unrenewed leader
slot. This is effectively the maximum duration that a leader can be stopped
before it is replaced by another candidate. This is only applicable if leader
election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRenewDeadline:
description: |-
The interval between attempts by the acting master to renew a leadership slot
before it stops leading. This must be less than or equal to the lease duration.
This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRetryPeriod:
description: |-
The duration the clients should wait between attempting acquisition and renewal
of a leadership. This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
registrationDriver:
description: This provides driver details required to register
with hub
Expand Down Expand Up @@ -407,6 +437,11 @@ spec:
the managed cluster. If not present, the default value of the work agent will be used.
pattern: ^([0-9]+(s|m|h))+$
type: string
disableLeaderElection:
description: |-
Disable leader election.
Use the klusterlet agent default value if this field is not defined.
type: boolean
featureGates:
description: "FeatureGates represents the list of feature gates
for work\nIf it is set empty, default feature gates will be
Expand Down Expand Up @@ -451,6 +486,31 @@ spec:
If it is set empty, use the default value: 50
format: int32
type: integer
leaderElectionLeaseDuration:
description: |-
The duration that non-leader candidates will wait after observing a leadership
renewal until attempting to acquire leadership of a led but unrenewed leader
slot. This is effectively the maximum duration that a leader can be stopped
before it is replaced by another candidate. This is only applicable if leader
election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRenewDeadline:
description: |-
The interval between attempts by the acting master to renew a leadership slot
before it stops leading. This must be less than or equal to the lease duration.
This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRetryPeriod:
description: |-
The duration the clients should wait between attempting acquisition and renewal
of a leadership. This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
type: object
workImagePullSpec:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ spec:
ClusterAnnotations is annotations with the reserve prefix "agent.open-cluster-management.io" set on
ManagedCluster when creating only, other actors can update it afterwards.
type: object
disableLeaderElection:
description: |-
Disable leader election.
Use the klusterlet agent default value if this field is not defined.
type: boolean
featureGates:
description: "FeatureGates represents the list of feature gates
for registration\nIf it is set empty, default feature gates
Expand Down Expand Up @@ -289,6 +294,31 @@ spec:
If it is set empty, use the default value: 50
format: int32
type: integer
leaderElectionLeaseDuration:
description: |-
The duration that non-leader candidates will wait after observing a leadership
renewal until attempting to acquire leadership of a led but unrenewed leader
slot. This is effectively the maximum duration that a leader can be stopped
before it is replaced by another candidate. This is only applicable if leader
election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRenewDeadline:
description: |-
The interval between attempts by the acting master to renew a leadership slot
before it stops leading. This must be less than or equal to the lease duration.
This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRetryPeriod:
description: |-
The duration the clients should wait between attempting acquisition and renewal
of a leadership. This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
registrationDriver:
description: This provides driver details required to register
with hub
Expand Down Expand Up @@ -407,6 +437,11 @@ spec:
the managed cluster. If not present, the default value of the work agent will be used.
pattern: ^([0-9]+(s|m|h))+$
type: string
disableLeaderElection:
description: |-
Disable leader election.
Use the klusterlet agent default value if this field is not defined.
type: boolean
featureGates:
description: "FeatureGates represents the list of feature gates
for work\nIf it is set empty, default feature gates will be
Expand Down Expand Up @@ -451,6 +486,31 @@ spec:
If it is set empty, use the default value: 50
format: int32
type: integer
leaderElectionLeaseDuration:
description: |-
The duration that non-leader candidates will wait after observing a leadership
renewal until attempting to acquire leadership of a led but unrenewed leader
slot. This is effectively the maximum duration that a leader can be stopped
before it is replaced by another candidate. This is only applicable if leader
election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRenewDeadline:
description: |-
The interval between attempts by the acting master to renew a leadership slot
before it stops leading. This must be less than or equal to the lease duration.
This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRetryPeriod:
description: |-
The duration the clients should wait between attempting acquisition and renewal
of a leadership. This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
type: object
workImagePullSpec:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ spec:
ClusterAnnotations is annotations with the reserve prefix "agent.open-cluster-management.io" set on
ManagedCluster when creating only, other actors can update it afterwards.
type: object
disableLeaderElection:
description: |-
Disable leader election.
Use the klusterlet agent default value if this field is not defined.
type: boolean
featureGates:
description: "FeatureGates represents the list of feature gates
for registration\nIf it is set empty, default feature gates
Expand Down Expand Up @@ -289,6 +294,31 @@ spec:
If it is set empty, use the default value: 50
format: int32
type: integer
leaderElectionLeaseDuration:
description: |-
The duration that non-leader candidates will wait after observing a leadership
renewal until attempting to acquire leadership of a led but unrenewed leader
slot. This is effectively the maximum duration that a leader can be stopped
before it is replaced by another candidate. This is only applicable if leader
election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRenewDeadline:
description: |-
The interval between attempts by the acting master to renew a leadership slot
before it stops leading. This must be less than or equal to the lease duration.
This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRetryPeriod:
description: |-
The duration the clients should wait between attempting acquisition and renewal
of a leadership. This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
registrationDriver:
description: This provides driver details required to register
with hub
Expand Down Expand Up @@ -407,6 +437,11 @@ spec:
the managed cluster. If not present, the default value of the work agent will be used.
pattern: ^([0-9]+(s|m|h))+$
type: string
disableLeaderElection:
description: |-
Disable leader election.
Use the klusterlet agent default value if this field is not defined.
type: boolean
featureGates:
description: "FeatureGates represents the list of feature gates
for work\nIf it is set empty, default feature gates will be
Expand Down Expand Up @@ -451,6 +486,31 @@ spec:
If it is set empty, use the default value: 50
format: int32
type: integer
leaderElectionLeaseDuration:
description: |-
The duration that non-leader candidates will wait after observing a leadership
renewal until attempting to acquire leadership of a led but unrenewed leader
slot. This is effectively the maximum duration that a leader can be stopped
before it is replaced by another candidate. This is only applicable if leader
election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRenewDeadline:
description: |-
The interval between attempts by the acting master to renew a leadership slot
before it stops leading. This must be less than or equal to the lease duration.
This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
leaderElectionRetryPeriod:
description: |-
The duration the clients should wait between attempting acquisition and renewal
of a leadership. This is only applicable if leader election is enabled.
Use the klusterlet agent default value if this field is not defined.
pattern: ^([0-9]+(s|m|h))+$
type: string
type: object
workImagePullSpec:
description: |-
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module open-cluster-management.io/ocm

go 1.22.5

replace open-cluster-management.io/api => github.com/haoqing0110/api v0.0.0-20241122094022-e75ef44f90de

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/evanphx/json-patch v5.9.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
github.com/haoqing0110/api v0.0.0-20241122094022-e75ef44f90de h1:4CC2iYkllPU/dP6FF2FlDREPkoWA2HfU+90W5gaLT0E=
github.com/haoqing0110/api v0.0.0-20241122094022-e75ef44f90de/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM=
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
Expand Down Expand Up @@ -453,8 +455,6 @@ k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 h1:MDF6h2H/h4tbzmtIKTuctcwZmY0tY
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
open-cluster-management.io/addon-framework v0.11.0 h1:ZJxphgHQ36VUJF0RIag+nzcEn5PNyep2rsEPdz6wT7o=
open-cluster-management.io/addon-framework v0.11.0/go.mod h1:ruMU8i/dciz3qCv2CQ46Cu1b7rkK7TpvB+W4bRwHf+I=
open-cluster-management.io/api v0.15.1-0.20241106012558-db876bf4ff8a h1:QTljOjTR8jDpw/EWhOoakGcStGVftQkBWHVxGZMhEUQ=
open-cluster-management.io/api v0.15.1-0.20241106012558-db876bf4ff8a/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM=
open-cluster-management.io/sdk-go v0.15.0 h1:2IAJnPfUoY6rPC5w7LhqAnvIlgekPoVW03LdZO1unIM=
open-cluster-management.io/sdk-go v0.15.0/go.mod h1:fi5WBsbC5K3txKb8eRLuP0Sim/Oqz/PHX18skAEyjiA=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 h1:2770sDpzrjjsAtVhSeUFseziht227YAWYHLGNM8QPwY=
Expand Down
13 changes: 12 additions & 1 deletion manifests/klusterlet/management/klusterlet-agent-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,19 @@ spec:
{{if .ExternalServerURL}}
- "--spoke-external-server-urls={{ .ExternalServerURL }}"
{{end}}
{{if eq .Replica 1}}
{{if .AgentDisableLeaderElection }}
- "--disable-leader-election"
{{end}}
{{if .AgentLeaderElectionLeaseDuration }}
- "--leader-election-lease-duration={{ .AgentLeaderElectionLeaseDuration }}"
{{end}}
{{if .AgentLeaderElectionRenewDeadline }}
- "--leader-election-renew-deadline={{ .AgentLeaderElectionRenewDeadline }}"
{{end}}
{{if .AgentLeaderElectionRetryPeriod }}
- "--leader-election-retry-period={{ .AgentLeaderElectionRetryPeriod }}"
{{end}}
{{if eq .Replica 1}}
- "--status-sync-interval=60s"
{{end}}
{{if gt .ClientCertExpirationSeconds 0}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,18 @@ spec:
- "--spoke-kubeconfig=/spoke/config/kubeconfig"
- "--terminate-on-files=/spoke/config/kubeconfig"
{{end}}
{{if eq .Replica 1}}
{{if .RegistrationDisableLeaderElection }}
- "--disable-leader-election"
{{end}}
{{if .RegistrationLeaderElectionLeaseDuration }}
- "--leader-election-lease-duration={{ .RegistrationLeaderElectionLeaseDuration }}"
{{end}}
{{if .RegistrationLeaderElectionRenewDeadline }}
- "--leader-election-renew-deadline={{ .RegistrationLeaderElectionRenewDeadline }}"
{{end}}
{{if .RegistrationLeaderElectionRetryPeriod }}
- "--leader-election-retry-period={{ .RegistrationLeaderElectionRetryPeriod }}"
{{end}}
{{if gt .ClientCertExpirationSeconds 0}}
- "--client-cert-expiration-seconds={{ .ClientCertExpirationSeconds }}"
{{end}}
Expand Down
Loading

0 comments on commit f72dbe6

Please sign in to comment.