Skip to content

Commit

Permalink
fix: enable leader election for fleet mode unless explicitly disabled…
Browse files Browse the repository at this point in the history
… by user
  • Loading branch information
pkoutsovasilis committed Dec 16, 2024
1 parent 8d6bee2 commit 81e13d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ stringData:
node: ${NODE_NAME}
scope: node
kubernetes_leaderelection:
enabled: false
enabled: true
leader_lease: example-pernode
---
# Source: elastic-agent/templates/agent/cluster-role.yaml
Expand Down Expand Up @@ -154,7 +154,7 @@ spec:
labels:
name: agent-pernode-example
annotations:
checksum/config: af3259ba23f68d99ef807759ff88472468ae32fe402c062fa164b19041d533c9
checksum/config: cd7c5c4f03cc8377d18ee22cf236428090959fc194ee647bd97a39b79f38c807
spec:
automountServiceAccountToken: true
containers:
Expand Down
7 changes: 6 additions & 1 deletion deploy/helm/elastic-agent/templates/agent/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ Validate and initialise the defined agent presets
{{- end -}}
{{- end -}}
{{- end -}}
{{/* by default we disable leader election but we also set the name of the leader lease in case it is explicitly enabled */}}
{{- if empty ($presetVal).providers -}}
{{- $_ := set $presetVal "providers" dict -}}
{{- end -}}
Expand All @@ -108,7 +107,13 @@ Validate and initialise the defined agent presets
{{- $_ := set $presetProviders "kubernetes_leaderelection" dict -}}
{{- end -}}
{{- $presetLeaderLeaseName := (printf "%s-%s" $.Release.Name $presetName) | lower -}}
{{/* by default we disable leader election but we also set the name of the leader lease in case it is explicitly enabled */}}
{{- $defaultLeaderElection := dict "enabled" false "leader_lease" $presetLeaderLeaseName -}}
{{- if eq $.Values.agent.fleet.enabled true -}}
{{/* for fleet mode the leader election is enabled by default */}}
{{- $_ := set $defaultLeaderElection "enabled" true -}}
{{- end -}}
{{/* merge the default leader election with the leader election from the preset giving priority to the one from the preset */}}
{{- $presetLeaderElection := mergeOverwrite dict $defaultLeaderElection ($presetProviders).kubernetes_leaderelection -}}
{{- $_ := set $presetProviders "kubernetes_leaderelection" $presetLeaderElection -}}
{{- end -}}
Expand Down

0 comments on commit 81e13d6

Please sign in to comment.