Allow defining unique election leader id

This commit is contained in:
Rolf Ahrenberg 2021-09-11 18:26:29 +03:00 committed by Yusuke Kuoka
parent e5b5ee6f1d
commit 5da808af96
3 changed files with 14 additions and 1 deletions

View File

@ -37,7 +37,12 @@ spec:
{{- $metricsHost := .Values.metrics.proxy.enabled | ternary "127.0.0.1" "0.0.0.0" }}
{{- $metricsPort := .Values.metrics.proxy.enabled | ternary "8080" .Values.metrics.port }}
- "--metrics-addr={{ $metricsHost }}:{{ $metricsPort }}"
{{- if .Values.controller.enableLeaderElection }}
- "--enable-leader-election"
{{- end }}
{{- if .Values.controller.leaderElectionId }}
- "--leader-election-id={{ .Values.controller.leaderElectionId }}"
{{- end }}
- "--sync-period={{ .Values.syncPeriod }}"
- "--docker-image={{ .Values.image.dindSidecarRepositoryAndTag }}"
- "--runner-image={{ .Values.image.actionsRunnerRepositoryAndTag }}"

View File

@ -8,6 +8,12 @@ replicaCount: 1
syncPeriod: 10m
controller:
enableLeaderElection: true
# Specifies the controller id for leader election.
# Must be unique if more than one controller installed.
#leaderElectionId: "actions-runner-controller"
# The controller tries its best not to repeat the duplicate GitHub API call
# within this duration.
# Defaults to syncPeriod - 10s.

View File

@ -65,6 +65,7 @@ func main() {
metricsAddr string
enableLeaderElection bool
leaderElectionId string
syncPeriod time.Duration
gitHubAPICacheDuration time.Duration
@ -87,6 +88,7 @@ func main() {
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
flag.StringVar(&leaderElectionId, "leader-election-id", "actions-runner-controller", "Controller id for leader election.")
flag.StringVar(&runnerImage, "runner-image", defaultRunnerImage, "The image name of self-hosted runner container.")
flag.StringVar(&dockerImage, "docker-image", defaultDockerImage, "The image name of docker sidecar container.")
flag.StringVar(&dockerRegistryMirror, "docker-registry-mirror", "", "The default Docker Registry Mirror used by runners.")
@ -129,7 +131,7 @@ func main() {
Scheme: scheme,
MetricsBindAddress: metricsAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "actions-runner-controller",
LeaderElectionID: leaderElectionId,
Port: 9443,
SyncPeriod: &syncPeriod,
Namespace: namespace,