summaryrefslogtreecommitdiffstats
path: root/kubernetes/dmaap/charts/postgresql/templates/deployment.yaml
blob: 57acfbda9bb221f49a79d1c5ca0b1dea581bb1ba (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ template "postgresql.fullname" . }}
  namespace: {{ .Values.global.nsPrefix }}
  labels:
    app: {{ template "postgresql.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  template:
    metadata:
      labels:
        app: {{ template "postgresql.fullname" . }}
    spec:
      {{- if .Values.affinity }}
      affinity:
{{ toYaml .Values.affinity | indent 8 }}
      {{- end }}
      {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
      {{- end }}
      {{- if .Values.tolerations }}
      tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
      {{- end }}
      {{- if .Values.schedulerName }}
      schedulerName: "{{ .Values.schedulerName }}"
      {{- end }}
      containers:
      - name: {{ template "postgresql.fullname" . }}
        image: "{{ .Values.image }}:{{ .Values.imageTag }}"
        imagePullPolicy: {{ default "" .Values.imagePullPolicy | quote }}
        args:
          {{- range $key, $value := default dict .Values.postgresConfig }}
          - -c
          - '{{ $key | snakecase }}={{ $value }}'
          {{- end }}
        env:
        - name: POSTGRES_USER
          value: {{ default "postgres" .Values.global.postgresUser | quote }}
          # Required for pg_isready in the health probes.
        - name: PGUSER
          value: {{ default "postgres" .Values.global.postgresUser | quote }}
        - name: POSTGRES_DB
          value: {{ default "" .Values.global.postgresDatabase | quote }}
        - name: POSTGRES_INITDB_ARGS
          value: {{ default "" .Values.postgresInitdbArgs | quote }}
        - name: PGDATA
          value: /var/lib/postgresql/data/pgdata
        - name: POSTGRES_PASSWORD
          value: {{ default "postgres" .Values.global.postgresPassword | quote }}
# original code:
#          valueFrom:
#            secretKeyRef:
#              name: {{ template "postgresql.fullname" . }}
#              key: postgres-password
        - name: POD_IP
          valueFrom: { fieldRef: { fieldPath: status.podIP } }
        ports:
        - name: postgresql
          containerPort: 5432
        livenessProbe:
          exec:
            command:
            - sh
            - -c
            - exec pg_isready --host $POD_IP
          initialDelaySeconds: 120
          timeoutSeconds: 5
          failureThreshold: 6
        readinessProbe:
          exec:
            command:
            - sh
            - -c
            - exec pg_isready --host $POD_IP
          initialDelaySeconds: 5
          timeoutSeconds: 3
          periodSeconds: 5
        resources:
{{ toYaml .Values.resources | indent 10 }}
        volumeMounts:
        - name: data
          mountPath: {{ .Values.persistence.mountPath }}
          subPath: {{ .Values.persistence.subPath }}
{{- if .Values.metrics.enabled }}
      - name: metrics
        image: "{{ .Values.metrics.image }}:{{ .Values.metrics.imageTag }}"
        imagePullPolicy: {{ default "" .Values.metrics.imagePullPolicy | quote }}
        env:
        - name: DATA_SOURCE_NAME
          value: postgresql://postgres@127.0.0.1:5432?sslmode=disable
        ports:
        - name: metrics
          containerPort: 9187
        {{- if .Values.metrics.customMetrics }}
        args: ["-extend.query-path", "/conf/custom-metrics.yaml"]
        volumeMounts:
          - name: custom-metrics
            mountPath: /conf
            readOnly: true
        {{- end }}
        resources:
{{ toYaml .Values.metrics.resources | indent 10 }}
{{- end }}
      volumes:
      - name: data
      {{- if .Values.persistence.enabled }}
        persistentVolumeClaim:
          claimName: {{ .Values.persistence.existingClaim | default (include "postgresql.fullname" .) }}
      {{- else }}
        emptyDir: {}
      {{- end }}
      {{- if and .Values.metrics.enabled .Values.metrics.customMetrics }}
      - name: custom-metrics
        secret:
          secretName: {{ template "postgresql.fullname" . }}
          items:
            - key: custom-metrics.yaml
              path: custom-metrics.yaml
      {{- end }}
      {{- if .Values.imagePullSecrets }}
      imagePullSecrets:
        - name: {{ .Values.imagePullSecrets }}
      {{- end }}