apiVersion: apps/v1
kind: Deployment
metadata:
  name: catalog-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: catalog-service
  template:
    metadata:
      annotations:
        prometheus.io/path: /actuator/prometheus
        prometheus.io/scrape: "true"
        prometheus.io/port: "9001"
    spec:
      containers:
        - name: catalog-service
          image: polarbookshop/catalog-service:0.0.1-SNAPSHOT
          imagePullPolicy: Always
          lifecycle:
            preStop:
              exec:
                command: [ "sh", "-c", "sleep 5" ]
          ports:
            - containerPort: 9001
          livenessProbe:
            httpGet:
              path: /actuator/health/liveness
              port: 9001
            initialDelaySeconds: 10
            periodSeconds: 5
          readinessProbe:
            httpGet:
              path: /actuator/health/readiness
              port: 9001
            initialDelaySeconds: 5
            periodSeconds: 15
          env:
            - name: BPL_JVM_THREAD_COUNT
              value: "25"
            - name: KEYCLOAK_URL
              value: http://polar-keycloak
          volumeMounts:
            - name: catalog-service-volume
              mountPath: /workspace/config
            - name: catalog-service-volume-secret
              mountPath: /workspace/secrets/catalog-service
      volumes:
        - name: catalog-service-volume
          configMap:
            name: catalog-service
        - name: catalog-service-volume-secret
          secret:
            secretName: catalog-service
