From 8097c2b3005e8d4e280a908445b93d432ab4509a Mon Sep 17 00:00:00 2001 From: Roi Kramer Date: Wed, 20 Sep 2023 19:12:22 +0300 Subject: [PATCH] fixed leader election --- .../templates/configmap.yaml | 1 + .../templates/deployment.yaml | 12 ++++++++++-- .../templates/secret.yaml | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/charts/ocean-kubernetes-controller/templates/configmap.yaml b/charts/ocean-kubernetes-controller/templates/configmap.yaml index 1c8cf09..5979fef 100644 --- a/charts/ocean-kubernetes-controller/templates/configmap.yaml +++ b/charts/ocean-kubernetes-controller/templates/configmap.yaml @@ -9,6 +9,7 @@ data: spotinst.cluster-identifier: {{ required "`spotinst.clusterIdentifier` must be specified" .Values.spotinst.clusterIdentifier }} base-url: {{ default "" .Values.spotinst.baseUrl | quote }} proxy-url: {{ default "" .Values.spotinst.proxyUrl | quote }} + leader-election: {{ gt (int .Values.replicas) 1 | quote }} disable-auto-update: {{ default "false" .Values.spotinst.disableAutoUpdate | quote }} enable-csr-approval: {{ default "false" .Values.spotinst.enableCsrApproval | quote }} {{- end }} diff --git a/charts/ocean-kubernetes-controller/templates/deployment.yaml b/charts/ocean-kubernetes-controller/templates/deployment.yaml index 0636f61..730572d 100644 --- a/charts/ocean-kubernetes-controller/templates/deployment.yaml +++ b/charts/ocean-kubernetes-controller/templates/deployment.yaml @@ -7,7 +7,7 @@ metadata: labels: {{- include "ocean-kubernetes-controller.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount }} + replicas: {{ .Values.replicas }} {{- with .Values.updateStrategy }} strategy: {{- toYaml . | nindent 4 }} @@ -18,8 +18,10 @@ spec: template: metadata: annotations: - # This will restart the deployment in case of configmap changes + # This will restart the deployment in case of configmap/secret changes checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} @@ -70,6 +72,12 @@ spec: name: {{ include "ocean-kubernetes-controller.configMapName" . }} key: spotinst.token optional: true + - name: SPOTINST_LEADER_ELECTION_ENABLED + valueFrom: + configMapKeyRef: + name: {{ include "ocean-kubernetes-controller.configMapName" . }} + key: leader-election + optional: true - name: SPOTINST_ACCOUNT_LEGACY valueFrom: configMapKeyRef: diff --git a/charts/ocean-kubernetes-controller/templates/secret.yaml b/charts/ocean-kubernetes-controller/templates/secret.yaml index 38f01b0..54d3405 100644 --- a/charts/ocean-kubernetes-controller/templates/secret.yaml +++ b/charts/ocean-kubernetes-controller/templates/secret.yaml @@ -7,6 +7,6 @@ metadata: {{- include "ocean-kubernetes-controller.labels" . | nindent 4 }} type: Opaque data: - token: {{ required "`spotinst.token` must be specified" .Values.spotinst.token | quote | b64enc }} - account: {{ required "`spotinst.account` must be specified" .Values.spotinst.account | quote | b64enc }} + token: {{ required "`spotinst.token` must be specified" .Values.spotinst.token | b64enc }} + account: {{ required "`spotinst.account` must be specified" .Values.spotinst.account | b64enc }} {{- end }}