bootstrap-job.yaml 5.36 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
{{- if or .Values.bootstrap.auth.secretName (or .Values.bootstrap.ddldml.raw .Values.bootstrap.ddldml.configMap) -}}
apiVersion: batch/v1
kind: Job
metadata:
  name: {{ include "influxdb-enterprise.fullname" . }}-bootstrap
  labels:
    {{- include "influxdb-enterprise.labels" . | nindent 4 }}
  annotations:
    "helm.sh/hook": post-install
    "helm.sh/hook-delete-policy": hook-succeeded
spec:
  activeDeadlineSeconds: 300
  backoffLimit: 10
  template:
    metadata:
      labels:
        {{- include "influxdb-enterprise.selectorLabels" . | nindent 8 }}
    spec:
      {{- if .Values.bootstrap.ddldml.configMap }}
      volumes:
      - name: ddldml
        configMap:
          name: {{ .Values.bootstrap.ddldml.configMap }}
      {{ end }}
      restartPolicy: OnFailure
26
      serviceAccountName: {{ template "influxdb-enterprise.serviceAccountName" . }}
27 28 29 30 31 32
      # Consider this a middleware of setup components.
      # Each is executed in-order until all of theme complete successfully.
      # This means that each command must be idempotent.
      initContainers:
      {{- if .Values.bootstrap.auth.secretName }}
      - name: auth
David McKay's avatar
David McKay committed
33
        {{- include "influxdb-enterprise.image" (dict "chart" .Chart "imageroot" .Values.image "podvals" .Values.data "podtype" "data") | indent 8 }}
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
        imagePullPolicy: {{ .Values.data.image.pullPolicy }}
        # Exposing these environment variables makes this command idempotent
        # as even if the authentication has been setup, we can still execute the command
        # and it won't error as nothing has changed
        env:
        - name: INFLUX_USERNAME
          valueFrom:
            secretKeyRef:
              name: {{ .Values.bootstrap.auth.secretName }}
              key: "username"
        - name: INFLUX_PASSWORD
          valueFrom:
            secretKeyRef:
              name: {{ .Values.bootstrap.auth.secretName }}
              key: "password"
        command:
          - influx
        args:
52 53 54 55 56 57
        {{- if .Values.data.https.enabled }}
          - -ssl 
        {{- if .Values.data.https.insecure }}
          - -unsafeSsl
        {{ end }}
        {{ end }}
58 59 60 61
          - -host
          - {{ include "influxdb-enterprise.fullname" . }}-data
          - -execute
          - CREATE USER $(INFLUX_USERNAME) WITH PASSWORD '$(INFLUX_PASSWORD)' WITH ALL PRIVILEGES
62 63 64
        resources:
          requests:
            cpu: 100m
65
            memory: 50Mi
66 67
          limits:
            cpu: 100m
68
            memory: 50Mi
69 70 71
      {{ end }}
      {{- if .Values.bootstrap.ddldml.configMap }}
      - name: ddl
David McKay's avatar
David McKay committed
72
        {{- include "influxdb-enterprise.image" (dict "chart" .Chart "imageroot" .Values.image "podvals" .Values.data "podtype" "data") | indent 8 }}
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
        imagePullPolicy: {{ .Values.data.image.pullPolicy }}
        {{- if .Values.bootstrap.auth.secretName }}
        env:
        - name: INFLUX_USERNAME
          valueFrom:
            secretKeyRef:
              name: {{ .Values.bootstrap.auth.secretName }}
              key: "username"
        - name: INFLUX_PASSWORD
          valueFrom:
            secretKeyRef:
              name: {{ .Values.bootstrap.auth.secretName }}
              key: "password"
        {{ end }}
        volumeMounts:
        - name: ddldml
          mountPath: /ddldml
        command:
          - influx
        args:
93 94 95 96 97 98
        {{- if .Values.data.https.enabled }}
          - -ssl 
        {{- if .Values.data.https.insecure }}
          - -unsafeSsl
        {{ end }}
        {{ end }}
99 100 101 102 103
          - -host
          - {{ include "influxdb-enterprise.fullname" . }}-data
          - -import
          - -path
          - /ddldml/ddl
104
        resources:
105
          {{- toYaml .Values.bootstrap.ddldml.resources | nindent 10 }}
106 107 108
      {{ end }}
      {{- if .Values.bootstrap.ddldml.configMap }}
      - name: dml
David McKay's avatar
David McKay committed
109
        {{- include "influxdb-enterprise.image" (dict "chart" .Chart "imageroot" .Values.image "podvals" .Values.data "podtype" "data") | indent 8 }}
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
        imagePullPolicy: {{ .Values.data.image.pullPolicy }}
        {{- if .Values.bootstrap.auth.secretName }}
        env:
        - name: INFLUX_USERNAME
          valueFrom:
            secretKeyRef:
              name: {{ .Values.bootstrap.auth.secretName }}
              key: "username"
        - name: INFLUX_PASSWORD
          valueFrom:
            secretKeyRef:
              name: {{ .Values.bootstrap.auth.secretName }}
              key: "password"
        {{ end }}
        volumeMounts:
        - name: ddldml
          mountPath: /ddldml
        command:
          - influx
        args:
130 131 132 133 134 135
        {{- if .Values.data.https.enabled }}
          - -ssl 
        {{- if .Values.data.https.insecure }}
          - -unsafeSsl
        {{ end }}
        {{ end }}
136 137 138 139 140
          - -host
          - {{ include "influxdb-enterprise.fullname" . }}-data
          - -import
          - -path
          - /ddldml/dml
141
        resources:
142
          {{- toYaml .Values.bootstrap.ddldml.resources | nindent 10 }}
143 144 145
      {{ end }}
      containers:
      - name: success
David McKay's avatar
David McKay committed
146
        {{- include "influxdb-enterprise.image" (dict "chart" .Chart "imageroot" .Values.image "podvals" .Values.data "podtype" "data") | indent 8 }}
147 148 149 150 151
        imagePullPolicy: {{ .Values.data.image.pullPolicy }}
        command:
          - echo
        args:
          - "Bootstrap Success"
152
        resources:
153 154
          requests:
            cpu: 100m
155
            memory: 50Mi
156 157
          limits:
            cpu: 100m
158
            memory: 50Mi
159
{{ end }}