apiVersion: apps/v1 kind: Deployment metadata: namespace: dev-1 name: postgres labels: app: postgres spec: replicas: 1 selector: matchLabels: app: postgres template: metadata: labels: app: postgres spec: containers: - name: postgres image: postgres:14.2 ports: - containerPort: 5432 env: - name: POSTGRES_DB valueFrom: secretKeyRef: name: pg-secrets key: db - name: POSTGRES_USER valueFrom: secretKeyRef: name: pg-secrets key: user - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: pg-secrets key: password volumeMounts: - mountPath: "/var/lib/postgresql/data" name: "pgdata" subPath: "postgres" volumes: - name: pgdata # This AWS EBS volume must already exist. awsElasticBlockStore: volumeID: "vol-02f06733d6bd7c009" fsType: ext4 --- kind: Service apiVersion: v1 metadata: name: postgres namespace: dev-1 labels: app: postgres spec: ports: - name: pgql protocol: TCP port: 5432 targetPort: 5432 selector: app: postgres