Skip to content

Ensure a unique lease object is created for each install of NIC via Helm #5388

@brianehlert

Description

@brianehlert

As an engineer, I would like to ensure that users can deploy multiple Ingress Controllers in the same name space without modifying the name of the leaderElectionLockName.

NOTE: This bug does not cover the lease object being managed by Helm

### UACs:
- [x] Update `_helper.tpl` to only generate the name of the lease
- [x] Update `charts/nginx-ingress/templates/controller-role.yaml` to use `nginx-ingress.leaderElectionName` instead of `.Values.controller.reportIngressStatus.leaderElectionLockName`

Changes required for fulfil requirements

  1. Update _helper.tpl to only generate the name:

Before:

{{- define "nginx-ingress.leaderElectionName" -}}
{{- if .Values.controller.reportIngressStatus.leaderElectionLockName -}}
{{ .Values.controller.reportIngressStatus.leaderElectionLockName }}
{{- else -}}
{{- printf "%s-%s" (include "nginx-ingress.fullname" .) "leader-election" -}}
{{- end -}}
{{- end -}}

After:

 {{- define "nginx-ingress.leaderElectionName" -}}
 {{- printf "%s-%s" (include "nginx-ingress.fullname" .) "leader-election" -}}
 {{- end -}}

Consideration:

 {{- define "nginx-ingress.leaderElectionName" -}}
 {{- printf "%s-%s" (include "nginx-ingress.fullname" .) .Values.controller.reportIngressStatus.leaderElectionLockName -}}
 {{- end -}}
  1. Update charts/nginx-ingress/templates/controller-role.yaml to use nginx-ingress.leaderElectionName instead of .Values.controller.reportIngressStatus.leaderElectionLockName

Before:

   resources:
   - leases
   resourceNames:
   - {{ .Values.controller.reportIngressStatus.leaderElectionLockName }}

After:

   resources:
   - leases
   resourceNames:
   - {{ include "nginx-ingress.leaderElectionName" . }}
  1. Remove .Values.controller.reportIngressStatus.leaderElectionLockName from values.yaml

Tested two deployments in the same namespace:

k get leases.coordination.k8s.io
NAME                                                   HOLDER                                                            AGE
leader-election-test-1-nginx-ingress-leader-election   leader-election-test-1-nginx-ingress-controller-75ff476494lbmnc   8m14s
leader-election-test-2-nginx-ingress-leader-election   leader-election-test-2-nginx-ingress-controller-7785c4fbc4qbckk   2s
k get deploy | grep leader-election
leader-election-test-1-nginx-ingress-controller   1/1     1            1           8m30s
leader-election-test-2-nginx-ingress-controller   1/1     1            1           17s

Metadata

Metadata

Assignees

Labels

backlogPull requests/issues that are backlog itemsbugAn issue reporting a potential bugproposalAn issue that proposes a feature requestrefinedIssues that are ready to be prioritized

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions