From ae5caa5be92da112abfa3f2f4adda4cf35e4b9f5 Mon Sep 17 00:00:00 2001 From: Shaun Date: Tue, 24 Jan 2023 16:59:03 +0000 Subject: [PATCH] Move logic for `-enable-leader-election` flag in helm templates (#3475) * Move logic for -enable-leader-election flag * Ensure -leader-election-lock-name is only set when leader election is enabled. * Fix formatting * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Venktesh Shivam Patel Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../helm-chart/templates/controller-daemonset.yaml | 4 +++- .../helm-chart/templates/controller-deployment.yaml | 2 ++ .../controller-leader-election-configmap.yaml | 10 ++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/deployments/helm-chart/templates/controller-daemonset.yaml b/deployments/helm-chart/templates/controller-daemonset.yaml index a1e4492cf2..34f44153ac 100644 --- a/deployments/helm-chart/templates/controller-daemonset.yaml +++ b/deployments/helm-chart/templates/controller-daemonset.yaml @@ -194,10 +194,12 @@ spec: - -external-service={{ .Values.controller.reportIngressStatus.externalService }} {{- else if and (.Values.controller.service.create) (eq .Values.controller.service.type "LoadBalancer") }} - -external-service={{ include "nginx-ingress.serviceName" . }} +{{- end }} {{- end }} - -enable-leader-election={{ .Values.controller.reportIngressStatus.enableLeaderElection }} + {{- if .Values.controller.reportIngressStatus.enableLeaderElection }} - -leader-election-lock-name={{ include "nginx-ingress.leaderElectionName" . }} -{{- end }} + {{- end }} {{- if .Values.controller.wildcardTLS.secret }} - -wildcard-tls-secret={{ .Values.controller.wildcardTLS.secret }} {{- else if and .Values.controller.wildcardTLS.cert .Values.controller.wildcardTLS.key }} diff --git a/deployments/helm-chart/templates/controller-deployment.yaml b/deployments/helm-chart/templates/controller-deployment.yaml index cb096e2694..35eedf5e9d 100644 --- a/deployments/helm-chart/templates/controller-deployment.yaml +++ b/deployments/helm-chart/templates/controller-deployment.yaml @@ -197,8 +197,10 @@ spec: - -external-service={{ .Values.controller.reportIngressStatus.externalService }} {{- else if and (.Values.controller.service.create) (eq .Values.controller.service.type "LoadBalancer") }} - -external-service={{ include "nginx-ingress.serviceName" . }} +{{- end }} {{- end }} - -enable-leader-election={{ .Values.controller.reportIngressStatus.enableLeaderElection }} +{{- if .Values.controller.reportIngressStatus.enableLeaderElection }} - -leader-election-lock-name={{ include "nginx-ingress.leaderElectionName" . }} {{- end }} {{- if .Values.controller.wildcardTLS.secret }} diff --git a/deployments/helm-chart/templates/controller-leader-election-configmap.yaml b/deployments/helm-chart/templates/controller-leader-election-configmap.yaml index ef6f79a581..a473c69a7a 100644 --- a/deployments/helm-chart/templates/controller-leader-election-configmap.yaml +++ b/deployments/helm-chart/templates/controller-leader-election-configmap.yaml @@ -1,3 +1,4 @@ +{{- if .Values.controller.reportIngressStatus.enableLeaderElection }} apiVersion: v1 kind: ConfigMap metadata: @@ -5,7 +6,8 @@ metadata: namespace: {{ .Release.Namespace }} labels: {{- include "nginx-ingress.labels" . | nindent 4 }} -{{- if .Values.controller.reportIngressStatus.annotations }} - annotations: -{{ toYaml .Values.controller.reportIngressStatus.annotations | indent 4 }} -{{- end }} + {{- if .Values.controller.reportIngressStatus.annotations }} +annotations: + {{ toYaml .Values.controller.reportIngressStatus.annotations | indent 4 }} + {{- end }} + {{- end }}