apiVersion: apps/v1
kind: Deployment
metadata:
  name: go-postgres
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 1
  selector:
    matchLabels:
      app: go-postgres
  template:
    metadata:
      labels:
        app: go-postgres
    spec:
      restartPolicy: Always
      terminationGracePeriodSeconds: 15
      containers:
        - name: go-postgres
          image: bygui86/go-postgres:latest
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: go-postgres
          env:
            - name: DB_USERNAME
              valueFrom:
                secretKeyRef:
                  name: postgresql
                  key: POSTGRES_USER
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgresql
                  key: POSTGRES_PASSWORD
          ports:
            - name: http
              containerPort: 8080
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 250m
              memory: 256Mi
