apiVersion: v1
kind: Service
metadata:
  labels:
    name: postgres-torus
  name: postgres-torus
spec:
  type: NodePort
  ports:
    - port: 5432
      targetPort: postgres-client
      nodePort: 30432
  selector:
    app: postgres-torus
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: postgres-torus
  labels:
    app: postgres-torus
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: postgres-torus
    spec:
      containers:
      - image: postgres
        name: postgres
        ports:
        - name: postgres-client
          containerPort: 5432
        volumeMounts:
        - name: data
          mountPath: /var/lib/postgresql/data
        env:
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: POSTGRES_PASSWORD
          value: testtorus
        - name: PGDATA
          value: "/var/lib/postgresql/data/pgdata"
      volumes:
        - name: data
          flexVolume:
            driver: "coreos.com/torus"
            fsType: "ext4"
            options:
              volume: "pg1"
              etcd: "10.3.0.100:2379"
