|
| 1 | +{{- define "deploy_utils.database.postgres.operator" }} |
| 2 | +--- |
| 3 | +apiVersion: v1 |
| 4 | +kind: Secret |
| 5 | +metadata: |
| 6 | + name: {{ printf "%s-credentials" .app.harness.database.name | quote }} |
| 7 | + namespace: {{ .root.Values.namespace }} |
| 8 | + labels: |
| 9 | + app: {{ .app.harness.database.name | quote }} |
| 10 | +{{ include "deploy_utils.labels" .root | indent 4 }} |
| 11 | +type: kubernetes.io/basic-auth |
| 12 | +stringData: |
| 13 | + username: {{ .app.harness.database.user | quote }} |
| 14 | + password: {{ .app.harness.database.pass | quote }} |
| 15 | +--- |
| 16 | +apiVersion: postgresql.cnpg.io/v1 |
| 17 | +kind: Cluster |
| 18 | +metadata: |
| 19 | + name: {{ .app.harness.database.name | quote }} |
| 20 | + namespace: {{ .root.Values.namespace }} |
| 21 | + labels: |
| 22 | + app: {{ .app.harness.database.name | quote }} |
| 23 | +{{ include "deploy_utils.labels" .root | indent 4 }} |
| 24 | +spec: |
| 25 | + instances: {{ .app.harness.database.postgres.instances | default 1 }} |
| 26 | + |
| 27 | + inheritedMetadata: |
| 28 | + labels: |
| 29 | + app: {{ .app.harness.database.name | quote }} |
| 30 | + service: db |
| 31 | + |
| 32 | + bootstrap: |
| 33 | + initdb: |
| 34 | + database: {{ .app.harness.database.postgres.initialdb | quote }} |
| 35 | + owner: {{ .app.harness.database.user | quote }} |
| 36 | + secret: |
| 37 | + name: {{ printf "%s-credentials" .app.harness.database.name | quote }} |
| 38 | + |
| 39 | + storage: |
| 40 | + size: {{ .app.harness.database.size }} |
| 41 | + |
| 42 | + {{- with .app.harness.database.resources }} |
| 43 | + resources: |
| 44 | + {{- with .requests }} |
| 45 | + requests: |
| 46 | + {{- with .memory }} |
| 47 | + memory: {{ . | quote }} |
| 48 | + {{- end }} |
| 49 | + {{- with .cpu }} |
| 50 | + cpu: {{ . | quote }} |
| 51 | + {{- end }} |
| 52 | + {{- end }} |
| 53 | + {{- with .limits }} |
| 54 | + limits: |
| 55 | + {{- with .memory }} |
| 56 | + memory: {{ . | quote }} |
| 57 | + {{- end }} |
| 58 | + {{- end }} |
| 59 | + {{- end }} |
| 60 | + |
| 61 | + {{- if .app.harness.database.image_ref }} |
| 62 | + imageName: {{ index (index .app "task-images") .app.harness.database.image_ref | default ("Image ref not found!" | quote) }} |
| 63 | + {{- else if .app.harness.database.postgres.image }} |
| 64 | + imageName: {{ .app.harness.database.postgres.image | quote }} |
| 65 | + {{- end }} |
| 66 | +--- |
| 67 | +apiVersion: v1 |
| 68 | +kind: Service |
| 69 | +metadata: |
| 70 | + name: {{ .app.harness.database.name | quote }} |
| 71 | + namespace: {{ .root.Values.namespace }} |
| 72 | + labels: |
| 73 | + app: {{ .app.harness.deployment.name | quote }} |
| 74 | +{{ include "deploy_utils.labels" .root | indent 4 }} |
| 75 | +spec: |
| 76 | + type: {{ if .app.harness.database.expose }}LoadBalancer{{ else }}ClusterIP{{ end }} |
| 77 | + selector: |
| 78 | + app: {{ .app.harness.database.name | quote }} |
| 79 | + cnpg.io/instanceRole: primary |
| 80 | + ports: |
| 81 | + {{- range $port := .app.harness.database.postgres.ports }} |
| 82 | + - name: {{ $port.name }} |
| 83 | + port: {{ $port.port }} |
| 84 | + targetPort: 5432 |
| 85 | + {{- end }} |
| 86 | +{{- end }} |
0 commit comments