From 3c50445b97495edd217a16e03c55bea5bff2642d Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Thu, 27 Jan 2022 16:38:50 +0000 Subject: [PATCH] Add Post Install Job which waits for cluster to be ready (#109) --- .../templates/atlas-cluster.yaml | 31 +++++++++++++++++++ charts/atlas-cluster/values.yaml | 8 +++++ 2 files changed, 39 insertions(+) diff --git a/charts/atlas-cluster/templates/atlas-cluster.yaml b/charts/atlas-cluster/templates/atlas-cluster.yaml index ae931bb0..60b58210 100644 --- a/charts/atlas-cluster/templates/atlas-cluster.yaml +++ b/charts/atlas-cluster/templates/atlas-cluster.yaml @@ -74,4 +74,35 @@ spec: {{- toYaml . | nindent 4 }} {{- end }} {{- end }} + +{{- if $.Values.postInstallHook.enabled }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ .name | quote }} + annotations: + "helm.sh/hook": post-install + "helm.sh/hook-weight": "1" + "helm.sh/hook-delete-policy": hook-succeeded,hook-failed +spec: + template: + metadata: + name: {{ .name | quote }} + labels: + app.kubernetes.io/managed-by: {{ .name | quote }} + app.kubernetes.io/instance: {{ .name | quote }} + spec: + serviceAccountName: mongodb-atlas-operator + restartPolicy: Never + containers: + - name: post-install-job + imagePullPolicy: Always + image: "{{ $.Values.postInstallHook.registry }}/{{ $.Values.postInstallHook.image }}:{{ $.Values.postInstallHook.version }}" + env: + - name: "CLUSTER_NAME" + value: "{{ .name }}" + - name: "NAMESPACE" + value: "{{ $.Release.Namespace }}" +{{- end }} {{- end }} diff --git a/charts/atlas-cluster/values.yaml b/charts/atlas-cluster/values.yaml index c65b936a..768fce7f 100644 --- a/charts/atlas-cluster/values.yaml +++ b/charts/atlas-cluster/values.yaml @@ -1,6 +1,14 @@ mongodb-atlas-operator: enabled: true +postInstallHook: + version: 1.0.0 + registry: quay.io/mongodb + image: atlas-operator-post-install-hook + # enabled "true" will create a post install job which waits for the created + # resources to reach the ready state. + enabled: false + # Please provide Atlas API credentials and Organization atlas: create: true