kind: Service apiVersion: v1 metadata: name: gitlab-db spec: selector: pod: gitlab-db ports: - protocol: TCP port: 5432 targetPort: 5432 --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: gitlab-db-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi --- apiVersion: apps/v1 kind: Deployment metadata: name: gitlab-db spec: replicas: 1 selector: matchLabels: pod: gitlab-db template: metadata: labels: pod: gitlab-db spec: containers: - name: gitlab-db image: postgres:alpine imagePullPolicy: IfNotPresent env: - name: POSTGRES_USER value: gitlab - name: POSTGRES_DB value: gitlabhq_production - name: POSTGRES_PASSWORD value: gitlab ports: - containerPort: 5432 volumeMounts: - name: gitlab-db-volume mountPath: /var/lib/postgresql/data subPath: gitlab volumes: - name: gitlab-db-volume persistentVolumeClaim: claimName: gitlab-db-pvc