apiVersion: apps/v1
kind: Deployment
metadata:
  name: book-app
  labels:
    app: book-app
  namespace: book-demo
spec:
  replicas: 2
  selector:
    matchLabels:
      app: book-app
  template:
    metadata:
      labels:
        app: book-app
    spec:
      containers:
        - name: book-app
          image: thomasvitale.azurecr.io/book-app:2.2.0
          ports:
            - containerPort: 8080
          resources:
            requests:
              memory: "756Mi"
              cpu: "0.5"
            limits:
              memory: "2Gi"
              cpu: "2"
          lifecycle:
            preStop:
              exec:
                command: [ "sh", "-c", "sleep 10" ]
          livenessProbe:
            httpGet:
              path: /actuator/health/liveness
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 5
          readinessProbe:
            httpGet:
              path: /actuator/health/readiness
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 5
          env:
            - name: SPRING_R2DBC_URL
              valueFrom:
                secretKeyRef:
                  key: url
                  name: postgres-creds
            - name: SPRING_R2DBC_USERNAME
              valueFrom:
                secretKeyRef:
                  key: username
                  name: postgres-creds
            - name: SPRING_R2DBC_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: password
                  name: postgres-creds
          volumeMounts:
            - name: config-volume
              mountPath: /workspace/config
      volumes:
        - name: config-volume
          configMap:
            name: book-config
