apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: stock-service
    version: v1
    app.kubernetes.io/component: backend
    app.kubernetes.io/instance: stock-service
    app.kubernetes.io/part-of: stock-service-app
    app.openshift.io/runtime: quarkus
  annotations:
    app.openshift.io/vcs-ref: main
    app.openshift.io/vcs-uri: 'https://github.com/lbroudoux/microservices-saga-blueprint'
  name: stock-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: stock-service
      version: v1
  template:
    metadata:
      labels:
        app: stock-service
        version: v1
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "8080"
        prometheus.io/scheme: "http"
        sidecar.istio.io/inject: "true"
    spec:
      containers:
        - image: quay.io/lbroudoux/microsaga-stock-service:1.0.0-SNAPSHOT
          imagePullPolicy: Always
          name: stock-service
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
            - containerPort: 8778
              name: jolokia
              protocol: TCP
          env:
            - name: DB_NAME
              valueFrom:
                secretKeyRef:
                  name: stock-database
                  key: database-name
            - name: DB_USERNAME
              valueFrom:
                secretKeyRef:
                  name: stock-database
                  key: database-user
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: stock-database
                  key: database-password
            - name: DB_URL
              value: jdbc:postgresql://stock-database:5432/${DB_NAME}
            - name: QUARKUS_PROFILE
              value: kube
          readinessProbe:
            httpGet:
              path: "q/health/ready"
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 5
            periodSeconds: 5
            timeoutSeconds: 2
          livenessProbe:
            httpGet:
              path: "q/health/live"
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 5
            periodSeconds: 5
            timeoutSeconds: 2
          securityContext:
            privileged: false
