apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    description: Postgres database for various data.
  labels:
    deploy: sourcegraph
  name: pgsql
spec:
  minReadySeconds: 10
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: pgsql
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: pgsql
        group: backend
    spec:
      containers:
      - env:
        - name: PGDATA
          value: /data/pgdata
        - name: POSTGRES_USER
          value: sg
        image: sourcegraph/postgres:9.4@sha256:eccea696a68cf9c7ff668398e80ecfadcac990d5f0b9aef15a107aa94128b632
        livenessProbe:
          initialDelaySeconds: 15
          tcpSocket:
            port: 5432
        name: pgsql
        ports:
        - containerPort: 5432
          name: pgsql
        resources:
          limits:
            cpu: "4"
            memory: 2Gi
          requests:
            cpu: 250m
            memory: 1G
        volumeMounts:
        - mountPath: /data
          name: disk
      - env:
        - name: DATA_SOURCE_NAME
          value: postgres://sg:@localhost:5432/?sslmode=disable
        image: sourcegraph/pgsql-exporter:a294a9b6d83c139d3e1217f02c8f80a54cbf73ac@sha256:a759be396e694ae112bcae5c1f94ac940dfdb51a39f219748ed6dea04e0355ad
        name: pgsql-exporter
        resources:
          limits:
            cpu: 10m
            memory: 50Mi
          requests:
            cpu: 10m
            memory: 50Mi
      securityContext:
        runAsUser: 0
      volumes:
      - name: disk
        persistentVolumeClaim:
          claimName: pgsql
