apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    io.kompose.service: postgrest
  name: postgrest
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: postgrest
  template:
    metadata:
      labels:
        io.kompose.service: postgrest
    spec:
      containers:
      - name: postgrest
        env:
        - name: POSTGRES_HOST
          valueFrom:
            configMapKeyRef:
              name: common-env
              key: POSTGRES_HOST_RO
        - name: POSTGRES_PORT
          valueFrom:
            configMapKeyRef:
              name: common-env
              key: POSTGRES_PORT
        - name: POSTGRES_DB
          valueFrom:
            configMapKeyRef:
              name: common-env
              key: POSTGRES_DB
        - name: POSTGRES_USER
          valueFrom:
            configMapKeyRef:
              name: common-env
              key: POSTGREST_USER_RO
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: init0-postgresql-ha-postgresql
              key: postgrest-ro-password
        - name: PGRST_DB_ANON_ROLE
          valueFrom:
            configMapKeyRef:
              name: common-env
              key: POSTGREST_USER_RO
        ports:
        - containerPort: 3000
        image: postgrest/postgrest:v7.0.1
        command: ["sh", "-c", "PGRST_DB_URI=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}; postgrest /etc/postgrest.conf"]
        imagePullPolicy: IfNotPresent
        resources: {}
        volumeMounts:
        - name: common-env
          mountPath: /run/secrets/common-env
          readOnly: true
        - name: postgres-password
          mountPath: /run/secrets/postgres-password
          readOnly: true
      restartPolicy: Always
      serviceAccountName: ""
      volumes:
      - name: common-env
        configMap:
          name: common-env
      - name: postgres-password
        secret:
          secretName: init0-postgresql-ha-postgresql
          items:
          - key: postgrest-ro-password
            path: POSTGREST_RO_PASSWORD
