apiVersion: apps/v1
kind: Deployment
metadata:
  name: producer
spec:
  selector:
    matchLabels:
      app: producer
      tier: backend
      track: stable
  replicas: 2
  template:
    metadata:
      labels:
        app: producer
        tier: backend
        track: stable
    spec:
      containers:
      - name: producer
        image: gcr.io/rpl-alelevininge/rpl-2.0:latest
        env:
        - name: SPRING_PROFILES_ACTIVE
          value: "producer,prod"
        - name: RPL_URL_FRONTEND
          value: http://www.myrpl.ar
        - name: JWT_SECRET
          valueFrom:
            secretKeyRef:
              name: jwt-secret
              key: secret
        - name: JWT_EXPIRATION_MS
          value: "43200000" # 12 hours
        - name: QUEUE_SERVICE_HOST
          value: queue
        - name: MYSQL_SERVICE_HOST
          valueFrom:
            secretKeyRef:
              name: db-host
              key: host
        - name: MYSQL_SERVICE_PORT
          value: "3306"
        - name: MYSQL_USERNAME
          valueFrom:
            secretKeyRef:
              name: db-username
              key: username
        - name: MYSQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: db-password
              key: password
        - name: MYSQL_DB_NAME
          valueFrom:
            secretKeyRef:
              name: db-name
              key: name
        - name: RPL_HELP_EMAIL_ADDRESS
          valueFrom:
            secretKeyRef:
              name: rpl-help-email
              key: email
        - name: RPL_HELP_EMAIL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: rpl-help-password
              key: password
        ports:
          - name: http
            containerPort: 8080
        readinessProbe:
          initialDelaySeconds: 300
          periodSeconds: 60
          httpGet:
            path: /api/health
            port: 8080
        livenessProbe:
          initialDelaySeconds: 300
          periodSeconds: 60
          failureThreshold: 3
          httpGet:
            path: /api/health
            port: 8080
        resources:
          requests:
            cpu: 350m
            memory: 512Mi
          limits:
            memory: 700Mi
