
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
  namespace: default
spec:
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:9.6.5
        ports:
        - containerPort: 5432 
        env:
        - name: POSTGRES_DB
          valueFrom:
            secretKeyRef:
              name: postgres
              key: db
        - name: POSTGRES_USER
          valueFrom:
            secretKeyRef:
              name: postgres
              key: user
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: postgres
              key: password