apiVersion: apps/v1
kind: Deployment
metadata:
  name: go-k8s-probes
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 1
  selector:
    matchLabels:
      app: go-k8s-probes
  template:
    metadata:
      labels:
        app: go-k8s-probes
    spec:
      restartPolicy: Always
      terminationGracePeriodSeconds: 15
      containers:
        - name: go-k8s-probes
          image: bygui86/go-k8s-probes
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: go-k8s-probes
          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
            - name: metrics
              containerPort: 9090
            - name: probes
              containerPort: 9091
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 250m
              memory: 256Mi
          livenessProbe:
            httpGet:
              path: /live
              port: 9091
            initialDelaySeconds: 15
            periodSeconds: 5
            timeoutSeconds: 3
            successThreshold: 1
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /ready
              port: 9091
            initialDelaySeconds: 10
            periodSeconds: 5
            timeoutSeconds: 3
            successThreshold: 1
            failureThreshold: 3
