A configuration management service with support for secrets.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

job-db-sync.yaml 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. {{/*
  2. Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */}}
  13. {{- if .Values.manifests.job_db_sync }}
  14. {{- $envAll := . }}
  15. {{- $dependencies := .Values.dependencies.db_sync }}
  16. {{- $mounts_deckhand_db_sync := .Values.pod.mounts.deckhand_db_sync.deckhand_db_sync }}
  17. {{- $mounts_deckhand_db_sync_init := .Values.pod.mounts.deckhand_db_sync.init_container }}
  18. {{- $serviceAccountName := "deckhand-db-sync" }}
  19. {{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
  20. ---
  21. apiVersion: batch/v1
  22. kind: Job
  23. metadata:
  24. name: deckhand-db-sync
  25. spec:
  26. template:
  27. metadata:
  28. labels:
  29. {{ tuple $envAll "deckhand" "db-sync" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
  30. spec:
  31. serviceAccountName: {{ $serviceAccountName }}
  32. restartPolicy: OnFailure
  33. nodeSelector:
  34. {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }}
  35. initContainers:
  36. {{ tuple $envAll $dependencies $mounts_deckhand_db_sync_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
  37. containers:
  38. - name: deckhand-db-sync
  39. image: {{ .Values.images.tags.db_sync | quote }}
  40. imagePullPolicy: {{ .Values.images.pull_policy | quote }}
  41. {{ tuple $envAll $envAll.Values.pod.resources.jobs.db_sync | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
  42. env:
  43. - name: DECKHAND_DB_URL
  44. valueFrom:
  45. secretKeyRef:
  46. name: {{ .Values.secrets.postgresql.user }}
  47. key: DATABASE_URI
  48. - name: DB_NAME
  49. valueFrom:
  50. secretKeyRef:
  51. name: {{ .Values.secrets.postgresql.user }}
  52. key: DATABASE_NAME
  53. - name: DB_SERVICE_USER
  54. valueFrom:
  55. secretKeyRef:
  56. name: {{ .Values.secrets.postgresql.user }}
  57. key: DATABASE_USERNAME
  58. - name: DB_SERVICE_PASSWORD
  59. valueFrom:
  60. secretKeyRef:
  61. name: {{ .Values.secrets.postgresql.user }}
  62. key: DATABASE_PASSWORD
  63. - name: DB_FQDN
  64. valueFrom:
  65. secretKeyRef:
  66. name: {{ .Values.secrets.postgresql.user }}
  67. key: DATABASE_HOST
  68. - name: DB_PORT
  69. valueFrom:
  70. secretKeyRef:
  71. name: {{ .Values.secrets.postgresql.user }}
  72. key: DATABASE_PORT
  73. - name: DB_ADMIN_USER
  74. valueFrom:
  75. secretKeyRef:
  76. name: {{ .Values.secrets.postgresql.admin }}
  77. key: DATABASE_USERNAME
  78. - name: PGPASSWORD
  79. valueFrom:
  80. secretKeyRef:
  81. name: {{ .Values.secrets.postgresql.admin }}
  82. key: DATABASE_PASSWORD
  83. command:
  84. - /tmp/db-sync.sh
  85. volumeMounts:
  86. - name: deckhand-bin
  87. mountPath: /tmp/db-sync.sh
  88. subPath: db-sync.sh
  89. readOnly: true
  90. - name: etc-deckhand
  91. mountPath: /etc/deckhand
  92. - name: deckhand-etc
  93. mountPath: /etc/deckhand/deckhand.conf
  94. subPath: deckhand.conf
  95. readOnly: true
  96. {{ if $mounts_deckhand_db_sync.volumeMounts }}{{ toYaml $mounts_deckhand_db_sync.volumeMounts | indent 10 }}{{ end }}
  97. volumes:
  98. - name: etc-deckhand
  99. emptyDir: {}
  100. - name: deckhand-etc
  101. configMap:
  102. name: deckhand-etc
  103. defaultMode: 0444
  104. - name: deckhand-bin
  105. configMap:
  106. name: deckhand-bin
  107. defaultMode: 0555
  108. {{ if $mounts_deckhand_db_sync.volumes }}{{ toYaml $mounts_deckhand_db_sync.volumes | indent 6 }}{{ end }}
  109. {{- end }}