summaryrefslogtreecommitdiff
path: root/charts/deckhand/templates/job-db-sync.yaml
blob: 5098ec20f181e2ee53ba2dfbb672f3027d8b4b33 (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{{/*
Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}

{{- if .Values.manifests.job_db_sync }}
{{- $envAll := . }}
{{- $dependencies := .Values.dependencies.db_sync }}
{{- $mounts_deckhand_db_sync := .Values.pod.mounts.deckhand_db_sync.deckhand_db_sync }}
{{- $mounts_deckhand_db_sync_init := .Values.pod.mounts.deckhand_db_sync.init_container }}
{{- $serviceAccountName := "deckhand-db-sync" }}
{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
---
apiVersion: batch/v1
kind: Job
metadata:
  name: deckhand-db-sync
spec:
  template:
    metadata:
      labels:
{{ tuple $envAll "deckhand" "db-sync" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
    spec:
      serviceAccountName: {{ $serviceAccountName }}
      restartPolicy: OnFailure
      nodeSelector:
        {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }}
      initContainers:
{{ tuple $envAll $dependencies $mounts_deckhand_db_sync_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
      containers:
        - name: deckhand-db-sync
          image: {{ .Values.images.tags.db_sync | quote }}
          imagePullPolicy: {{ .Values.images.pull_policy | quote }}
{{ tuple $envAll $envAll.Values.pod.resources.jobs.db_sync | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
          env:
            - name: DECKHAND_DB_URL
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.secrets.postgresql.user }}
                  key: DATABASE_URI
            - name: DB_NAME
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.secrets.postgresql.user }}
                  key: DATABASE_NAME
            - name: DB_SERVICE_USER
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.secrets.postgresql.user }}
                  key: DATABASE_USERNAME
            - name: DB_SERVICE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.secrets.postgresql.user }}
                  key: DATABASE_PASSWORD
            - name: DB_FQDN
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.secrets.postgresql.user }}
                  key: DATABASE_HOST
            - name: DB_PORT
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.secrets.postgresql.user }}
                  key: DATABASE_PORT
            - name: DB_ADMIN_USER
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.secrets.postgresql.admin }}
                  key: DATABASE_USERNAME
            - name: PGPASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.secrets.postgresql.admin }}
                  key: DATABASE_PASSWORD
          command:
            - /tmp/db-sync.sh
          volumeMounts:
            - name: deckhand-bin
              mountPath: /tmp/db-sync.sh
              subPath: db-sync.sh
              readOnly: true
            - name: etc-deckhand
              mountPath: /etc/deckhand
            - name: deckhand-etc
              mountPath: /etc/deckhand/deckhand.conf
              subPath: deckhand.conf
              readOnly: true
{{ if $mounts_deckhand_db_sync.volumeMounts }}{{ toYaml $mounts_deckhand_db_sync.volumeMounts | indent 10 }}{{ end }}
      volumes:
        - name: etc-deckhand
          emptyDir: {}
        - name: deckhand-etc
          configMap:
            name: deckhand-etc
            defaultMode: 0444
        - name: deckhand-bin
          configMap:
            name: deckhand-bin
            defaultMode: 0555
{{ if $mounts_deckhand_db_sync.volumes }}{{ toYaml $mounts_deckhand_db_sync.volumes | indent 6 }}{{ end }}
{{- end }}