apiVersion: apps/v1
kind: Deployment
metadata:
  name: cycling-blog-db
  namespace: golang-app
  labels: 
    app: cycling-blog-db
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cycling-blog-db
  template:
    metadata:
      labels:
        app: cycling-blog-db
    spec: 
      containers:
      - name: cycling-blog-db
        image: postgres:13-alpine
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "128Mi"
            cpu: "500m"
        env:
        - name: POSTGRES_USER
          value: demouser
        - name: POSTGRES_PASSWORD
          value: P455w0rd
        - name: POSTGRES_DB
          value: cyclingblog
        - name: HOSTANME
          value: cyclingblog-db
        ports:
        - containerPort: 8080
          protocol: TCP
        volumeMounts:
        - name: postgres
          mountPath: /var/lib/postgresql/data
        - name: script-volume
          mountPath: /scripts-volume
      volumes:
      - name: postgres
        hostPath:
          path: /var/lib/postgresql/data
          type: DirectoryOrCreate
      - name: script-volume
        hostPath:
          path: /scripts-volume
          type: DirectoryOrCreate
