Skip to content

Commit 35ec9e8

Browse files
feat(gitops-operator): set LEADER_ELECT based on replicaCount (#419)
1 parent 0887e62 commit 35ec9e8

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

charts/gitops-runtime/templates/gitops-operator.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
{{- $_ := set $gitopsOperatorContext.Values.global.codefresh.tls.caCerts.secretKeyRef "key" (.Values.global.codefresh.tls.caCerts.secret.create | ternary (default "ca-bundle.crt" .Values.global.codefresh.tls.caCerts.secret.key) .Values.global.codefresh.tls.caCerts.secretKeyRef.key) }}
3636
{{- end }}
3737

38+
{{- if and (gt (int $gitopsOperatorContext.Values.replicaCount) 1 ) }}
39+
{{- $_ := set $gitopsOperatorContext.Values.env "LEADER_ELECT" "true" }}
40+
{{- else }}
41+
{{- $_ := set $gitopsOperatorContext.Values.env "LEADER_ELECT" "false" }}
42+
{{- end }}
43+
3844
{{- include "gitops-operator.resources" $gitopsOperatorContext}}
3945

4046
{{- end }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
suite: Test GitOps Operator
2+
templates:
3+
- gitops-operator.yaml
4+
- charts/gitops-operator/*
5+
tests:
6+
- it: should have LEADER_ELECT set to true if replicaCount is greater than 1
7+
values:
8+
- ./values/mandatory-values.yaml
9+
template: gitops-operator.yaml
10+
documentSelector:
11+
path: kind
12+
value: Deployment
13+
set:
14+
gitops-operator.replicaCount: 2
15+
asserts:
16+
- contains:
17+
path: spec.template.spec.containers[1].env
18+
content:
19+
name: LEADER_ELECT
20+
value: "true"
21+
22+
- it: should have LEADER_ELECT set to false if replicaCount is 1
23+
values:
24+
- ./values/mandatory-values.yaml
25+
template: gitops-operator.yaml
26+
documentSelector:
27+
path: kind
28+
value: Deployment
29+
set:
30+
gitops-operator.replicaCount: 1
31+
asserts:
32+
- contains:
33+
path: spec.template.spec.containers[1].env
34+
content:
35+
name: LEADER_ELECT
36+
value: "false"

0 commit comments

Comments
 (0)