diff --git a/charts/nginx-ingress/templates/controller-lease.yaml b/charts/nginx-ingress/templates/controller-lease.yaml new file mode 100644 index 0000000000..960f61cea0 --- /dev/null +++ b/charts/nginx-ingress/templates/controller-lease.yaml @@ -0,0 +1,13 @@ +{{ if .Values.controller.reportIngressStatus.enableLeaderElection }} +apiVersion: coordination.k8s.io/v1 +kind: Lease +metadata: + name: {{ include "nginx-ingress.leaderElectionName" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "nginx-ingress.labels" . | nindent 4 }} +{{- if .Values.controller.reportIngressStatus.annotations }} + annotations +{{ toYaml .Values.controller.reportIngressStatus.annotations | indent 4 }} +{{- end }} +{{- end }} diff --git a/charts/nginx-ingress/templates/controller-role.yaml b/charts/nginx-ingress/templates/controller-role.yaml index e902381775..cb75d99cc3 100644 --- a/charts/nginx-ingress/templates/controller-role.yaml +++ b/charts/nginx-ingress/templates/controller-role.yaml @@ -43,7 +43,7 @@ rules: resources: - leases resourceNames: - - {{ .Values.controller.reportIngressStatus.leaderElectionLockName }} + - {{ include "nginx-ingress.leaderElectionName" . }} verbs: - get - update diff --git a/charts/nginx-ingress/values.yaml b/charts/nginx-ingress/values.yaml index 002102bfb1..ebece1f3a6 100644 --- a/charts/nginx-ingress/values.yaml +++ b/charts/nginx-ingress/values.yaml @@ -496,7 +496,8 @@ controller: enableLeaderElection: true ## Specifies the name to be used as the lock for leader election. controller.reportIngressStatus.enableLeaderElection must be set to true. - leaderElectionLockName: "nginx-ingress-leader" + ## The default is autogenerated. + leaderElectionLockName: "" ## The annotations of the leader election configmap. annotations: {}