apiVersion: apps/v1
kind: Deployment
metadata:
  name: appdeploy
  labels:
    app: asset-app
spec:
  selector:
    matchLabels:
      app: asset-app
  replicas: 3
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: asset-app
    spec:
      containers:
        - name: appdeploy
          image: dock-reg-0001.ml/asset-app:0.1.4
          imagePullPolicy: Always
#          resources:
#            limits:
#              memory: "400Mi"
#              cpu: "200m"
#            requests:
#              memory: "100Mi"
#              cpu: "100m"
          env:
            - name: MYSQL_HOST
              valueFrom:
                configMapKeyRef:
                  name: app-config
                  key: MYSQL_HOST
            - name: MYSQL_PORT
              valueFrom:
                configMapKeyRef:
                  name: app-config
                  key: MYSQL_PORT
            - name: REDIS_HOST
              valueFrom:
                configMapKeyRef:
                  name: app-config
                  key: REDIS_HOST
            - name: REDIS_PORT
              valueFrom:
                configMapKeyRef:
                  name: app-config
                  key: REDIS_PORT
            - name: MYSQL_USER
              valueFrom:
                secretKeyRef:
                  name: mysql-secret
                  key: MYSQL_USER
            - name: MYSQL_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql-secret
                  key: MYSQL_PASSWORD
            - name: MYSQL_DATABASE
              valueFrom:
                secretKeyRef:
                  name: mysql-secret
                  key: MYSQL_DATABASE
            - name: SECRET_KEY
              valueFrom:
                secretKeyRef:
                  name: app-secret
                  key: SECRET_KEY
#                  alternative1: use a file as a volume mount
#                  alternative2: use Hashicorp Vault
          ports:
            - containerPort: 5000
          readinessProbe:
            httpGet:
              path: /ready
              port: 5000
          livenessProbe:
            httpGet:
              path: /health
              port: 5000
            initialDelaySeconds: 3
            periodSeconds: 3
      imagePullSecrets:
        - name: regcred

