apiVersion: apps/v1 kind: Deployment metadata: labels: service: postgres name: postgres spec: replicas: 1 selector: matchLabels: service: postgres strategy: type: Recreate template: metadata: labels: service: postgres spec: containers: - env: - name: POSTGRES_HOST_AUTH_METHOD value: trust image: postgres:latest name: postgres ports: - containerPort: 5432 resources: {} volumeMounts: - mountPath: /var/lib/postgresql/data name: db-data restartPolicy: Always volumes: - name: db-data persistentVolumeClaim: claimName: db-data status: {} --- apiVersion: v1 kind: Service metadata: labels: service: postgres name: postgres spec: ports: - name: "5432" port: 5432 targetPort: 5432 selector: service: postgres status: loadBalancer: {}