Merge branch 'master' of https://github.com/mluds/arvados-k8s into mluds-master
[arvados-k8s.git] / charts / arvados / templates / postgres-deployment.yaml
index 183137253086765db8d84a4509a234d4b2ff74a9..d820e8eeff69e94ab909e21d91a9099c9d8e4139 100644 (file)
@@ -3,7 +3,7 @@
 # SPDX-License-Identifier: Apache-2.0
 
 apiVersion: apps/v1
-kind: Deployment
+kind: StatefulSet
 metadata:
   name: "arvados-postgres"
   labels:
@@ -12,6 +12,9 @@ metadata:
     release: {{ .Release.Name }}
     heritage: {{ .Release.Service }}
 spec:
+  replicas: 1
+  podManagementPolicy: Parallel
+  serviceName: arvados-postgres
   selector:
     matchLabels:
       app: arvados-postgres
@@ -22,15 +25,40 @@ spec:
         app: arvados-postgres
         release: {{ .Release.Name }}
     spec:
+      terminationGracePeriodSeconds: 1
       containers:
         - name: {{ .Chart.Name }}
           image: "postgres:9.5"
           imagePullPolicy: {{ .Values.image.pullPolicy }}
+          env:
+            - name: POSTGRES_HOST_AUTH_METHOD
+              value: "trust"
           volumeMounts:
             - name: postgres-configmap
               mountPath: /docker-entrypoint-initdb.d/create_dbs.sh
               subPath: create_dbs.sh
+            {{- if .Values.postgres.persistence.enabled }}
+            - name: postgres-storage
+              mountPath: /var/lib/postgresql/data
+            {{- end }}
       volumes:
         - name: postgres-configmap
           configMap:
             name: postgres-configmap
+        {{- if .Values.postgres.persistence.enabled }}
+        - name: postgres-storage
+          persistentVolumeClaim:
+            claimName: {{ .Release.Name }}-postgres-pvc
+        {{- end }}
+  {{- if .Values.postgres.persistence.enabled }}
+  volumeClaimTemplates:
+    - metadata:
+        name: postgres-storage
+      spec:
+        storageClassName: {{ .Values.postgres.persistence.storageClass }}
+        accessModes:
+          - ReadWriteOnce
+        resources:
+          requests:
+            storage: {{ .Values.postgres.persistence.size }}
+  {{- end }}