apiVersion: apps/v1
kind: Deployment
metadata:
  name: sc-order-service-deployment
  namespace: default
  labels:
    app: sc-order-service
spec:
  replicas: 2
  selector:
    matchLabels:
      app: sc-order-service
  template:
    metadata:
      labels:
        app: sc-order-service
    spec:
      containers:
        - name: sc-order-service
          image: tsalm/sc-order-service
          ports:
            - containerPort: 8080
          env:
            - name: SPRING_DATASOURCE_USERNAME
              valueFrom:
                secretKeyRef:
                  name: sc-order-service-database-secret
                  key: username
            - name: SPRING_DATASOURCE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: sc-order-service-database-secret
                  key: password
            - name: ORDER_DATABASE_NAME
              valueFrom:
                configMapKeyRef:
                  name: sc-order-service-database-configmap
                  key: database
            - name: SPRING_REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: sc-order-service-cache-secret
                  key: password
            - name: SPRING_RABBITMQ_USERNAME
              valueFrom:
                secretKeyRef:
                  name: sc-message-broker-secret
                  key: username
            - name: SPRING_RABBITMQ_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: sc-message-broker-secret
                  key: password
            - name: MANAGEMENT_METRICS_EXPORT_WAVEFRONT_API_TOKEN
              valueFrom:
                secretKeyRef:
                  name: sc-wavefront-secret
                  key: api-token
                  optional: true
            - name: MANAGEMENT_METRICS_EXPORT_WAVEFRONT_URI
              valueFrom:
                secretKeyRef:
                  name: sc-wavefront-secret
                  key: uri
                  optional: true
          livenessProbe:
            initialDelaySeconds: 60
            periodSeconds: 3
            httpGet:
              path: /actuator/health/liveness
              port: 8080
          readinessProbe:
            initialDelaySeconds: 60
            periodSeconds: 10
            httpGet:
              path: /actuator/health/readiness
              port: 8080
          resources:
            requests:
              memory: 768Mi
              cpu: 500m
            limits:
              memory: 768Mi