aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes/postgres/postgres-deployment.yaml
blob: 2711117e856d380c0769baf5042dba7d5a29a832 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
apiVersion: apps/v1
kind: Deployment
metadata:
  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-alpine3.15
        ports:
          - containerPort: 5432
        env:
          # - name: POSTGRES_USER
          #   valueFrom:
          #     secretKeyRef:
          #       name: postgres-secrets
          #       key: postgres-user
          #       optional: false
          # - name: POSTGRES_DB
          #   valueFrom:
          #     secretKeyRef:
          #       name: postgres-secrets
          #       key: postgres-db
          #       optional: false
          - name: POSTGRES_PASSWORD
            valueFrom:
              secretKeyRef:
                name: postgres-secrets
                key: postgres-password
                optional: false
          # - name: POSTGRES_INITDB_ARGS
          #   valueFrom:
          #     secretKeyRef:
          #       name: postgres-secrets
          #       key: postgres-initdb-args
          #       optional: false
          - name: POSTGRES_HOST_AUTH_METHOD
            valueFrom:
              secretKeyRef:
                name: postgres-secrets
                key: postgres-host-auth-method
                optional: false
        volumeMounts:
          - name: postgres-data
            mountPath: /var/lib/postgres/data
      volumes:
        - name: postgres-data
          persistentVolumeClaim:
            claimName: postgres-data
---
apiVersion: v1
kind: Service
metadata:
  name: postgres-service
spec:
  selector:
    app: postgres
  type: LoadBalancer
  ports:
    - protocol: TCP
      name: "5432"
      port: 5432
      targetPort: 5432
      nodePort: 30432