diff --git a/charts/kamaji-etcd/Chart.yaml b/charts/kamaji-etcd/Chart.yaml index 476f5bc..9acbe8d 100644 --- a/charts/kamaji-etcd/Chart.yaml +++ b/charts/kamaji-etcd/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.5.0 +version: 0.5.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/kamaji-etcd/README.md b/charts/kamaji-etcd/README.md index b0e4c75..d23b1b2 100644 --- a/charts/kamaji-etcd/README.md +++ b/charts/kamaji-etcd/README.md @@ -1,6 +1,6 @@ # kamaji-etcd -![Version: 0.5.0](https://img.shields.io/badge/Version-0.5.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.5.6](https://img.shields.io/badge/AppVersion-3.5.6-informational?style=flat-square) +![Version: 0.5.1](https://img.shields.io/badge/Version-0.5.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.5.6](https://img.shields.io/badge/AppVersion-3.5.6-informational?style=flat-square) Helm chart for deploying a multi-tenant `etcd` cluster. diff --git a/charts/kamaji-etcd/templates/etcd_job_preinstall_1.yaml b/charts/kamaji-etcd/templates/etcd_job_preinstall_1.yaml index 28a5a26..b53436d 100644 --- a/charts/kamaji-etcd/templates/etcd_job_preinstall_1.yaml +++ b/charts/kamaji-etcd/templates/etcd_job_preinstall_1.yaml @@ -36,13 +36,21 @@ spec: containers: - name: kubectl image: {{ printf "clastix/kubectl:%s" (include "etcd.jobsTagKubeVersion" .) }} - command: - - sh - - -c - - |- - kubectl --namespace={{ .Release.Namespace }} delete secret --ignore-not-found=true {{ include "etcd.caSecretName" . }} {{ include "etcd.clientSecretName" . }} && - kubectl --namespace={{ .Release.Namespace }} create secret generic {{ include "etcd.caSecretName" . }} --from-file=/certs/ca.crt --from-file=/certs/ca.key --from-file=/certs/peer-key.pem --from-file=/certs/peer.pem --from-file=/certs/server-key.pem --from-file=/certs/server.pem && - kubectl --namespace={{ .Release.Namespace }} create secret tls {{ include "etcd.clientSecretName" . }} --key=/certs/root-client-key.pem --cert=/certs/root-client.pem + command: ["/bin/sh", "-c"] + args: + - | + if kubectl get secret {{ include "etcd.caSecretName" . }} --namespace={{ .Release.Namespace }} &>/dev/null; then + echo "Secret {{ include "etcd.caSecretName" . }} already exists" + else + echo "Creating secret {{ include "etcd.caSecretName" . }}" + kubectl --namespace={{ .Release.Namespace }} create secret generic {{ include "etcd.caSecretName" . }} --from-file=/certs/ca.crt --from-file=/certs/ca.key --from-file=/certs/peer-key.pem --from-file=/certs/peer.pem --from-file=/certs/server-key.pem --from-file=/certs/server.pem + fi + if kubectl get secret {{ include "etcd.clientSecretName" . }} --namespace={{ .Release.Namespace }} &>/dev/null; then + echo "Secret {{ include "etcd.clientSecretName" . }} already exists" + else + echo "Creating secret {{ include "etcd.clientSecretName" . }}" + kubectl --namespace={{ .Release.Namespace }} create secret tls {{ include "etcd.clientSecretName" . }} --key=/certs/root-client-key.pem --cert=/certs/root-client.pem + fi volumeMounts: - mountPath: /certs name: certs diff --git a/charts/kamaji-etcd/templates/etcd_job_preinstall_2.yaml b/charts/kamaji-etcd/templates/etcd_job_preinstall_2.yaml index 64400b3..5012e5e 100644 --- a/charts/kamaji-etcd/templates/etcd_job_preinstall_2.yaml +++ b/charts/kamaji-etcd/templates/etcd_job_preinstall_2.yaml @@ -29,11 +29,15 @@ spec: - bash - -c - |- - etcdctl member list -w table && - etcdctl user add --no-password=true root && - etcdctl role add root && - etcdctl user grant-role root root && - etcdctl auth enable + etcdctl member list -w table + if etcdctl user get root &>/dev/null; then + echo "User already exists, nothing to do" + else + etcdctl user add --no-password=true root && + etcdctl role add root && + etcdctl user grant-role root root && + etcdctl auth enable + fi env: - name: ETCDCTL_ENDPOINTS value: https://{{ include "etcd.fullname" . }}-0.{{ include "etcd.serviceName" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.clientPort }}