apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: spilodemo
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: spilodemo
    spec:
      containers:
        - name: spilodemo
          image: registry.example.com/spilok8s:9.5
          imagePullPolicy: Always
          ports:
          - containerPort: 8008
          - containerPort: 5432
          env:
          - name: PGPASSWORD_SUPERUSER
            value: tea
          - name: PGPASSWORD_ADMIN
            value: cola
          - name: PGPASSWORD_STANDBY
            value: pinacolada
          - name: ETCD_DISCOVERY_DOMAIN
            value: etcd.default.svc.cluster.local
          - name: SCOPE
            value: spilotestp5
          - name: WAL_GCS_BUCKET
            value: spilo-example

---

apiVersion: v1
kind: Service
metadata:
  name: spilodemo-lb-service
  labels:
    app: spilodemo-lb
spec:
  type: LoadBalancer
  ports:
  - port: 5432
    targetPort: 5432
  selector:
    app: spilodemo
    spilo-role: master

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: spilodemo
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: spilodemo
    spec:
      containers:
        - name: spilodemo
          image: registry.example.com/spilok8s:9.5
          imagePullPolicy: Always
          ports:
          - containerPort: 8008
          - containerPort: 5432
          env:
          - name: PGPASSWORD_SUPERUSER
            value: tea
          - name: PGPASSWORD_ADMIN
            value: cola
          - name: PGPASSWORD_STANDBY
            value: pinacolada
          - name: ETCD_DISCOVERY_DOMAIN
            value: etcd.default.svc.cluster.local
          - name: SCOPE
            value: spilotestp5
          - name: WAL_GCS_BUCKET
            value: spilo-example
         - name: PGDATA
            value: /home/postgres/pgdata
          volumeMounts:
            - mountPath: /home/postgres/pgdata
              name: pgdata
    volumes:
      - name: pgdata
        PersistentVolumeClaim:
          claimName: pvc-pgdata

---

apiVersion: v1
kind: Service
metadata:
  name: spilodemo-lb-service
  labels:
    app: spilodemo-lb
spec:
  type: LoadBalancer
  ports:
  - port: 5432
    targetPort: 5432
  selector:
    app: spilodemo
    spilo-role: master

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-pgdata
  namespace: spilodemo
  annotations:
    volume.alpha.kubernetes.io/storage-class: anything
spec:
  accessModes:
  - ReadWriteOnes
  resources:
    requests:
      storage: 10Gi

Use persistent volumes on K8s.
Use persistent volumes on K8s.
