---
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: development
  name: jarvis-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: jarvis-api
  template:
    metadata:
      labels:
        namespace: development
        app: jarvis-api
    spec:
      containers:
      - name: application
        image: samwang0723/jarvis-api:latest
        imagePullPolicy: Always
        ports:
        - name: rest-api-port
          containerPort: 8080
        - name: grpc-port
          containerPort: 8081
        - name: mysql-port
          containerPort: 3306
        - name: redis-port
          containerPort: 6379
        - name: http-port
          containerPort: 80
        - name: https-port
          containerPort: 443
        # define a liveness probe that checks every 5 seconds, starting after 5 seconds
        livenessProbe:
          httpGet:
            path: /live
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 5
        # define a readiness probe that checks every 5 seconds
        readinessProbe:
          httpGet:
            path: /ready
            port: 8080
          periodSeconds: 5
        env:
        - name: MY_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: ENVIRONMENT
          value: "production"
        - name: START_CRON
          value: "true"
        - name: SECRET_USERNAME
          valueFrom:
            secretKeyRef:
              name: database-secret
              key: username
        - name: SECRET_PASSWORD
          valueFrom:
            secretKeyRef:
              name: database-secret
              key: password
        - name: DAILYCLOSE_PROXY
          valueFrom:
            secretKeyRef:
              name: proxy-secret-dailyclose
              key: token
        - name: CONCENTRATION_PROXY
          valueFrom:
            secretKeyRef:
              name: proxy-secret-concentration
              key: token
