apiVersion: apps/v1
kind: Deployment
metadata:
  name: flask-app
  namespace: default
spec:
  replicas: 2
  selector:
    matchLabels:
      app: flask-ipl-app
  template:
    metadata:
      labels:
        app: flask-ipl-app
    spec:
      containers:
      - image: punithmgp/flask-ipl:v1.0
        name: ipl-app
        imagePullPolicy: ifNotPresent
        resources:
          limits:
            cpu: "200m"
            memory: "128Mi"
          requests:
            cpu: "100m"
            memory: "128Mi"
        ports:
        - containerPort: 5000
          protocol: TCP
        env:
        # name is the ENV variable name which will be read by the app.
        - name: NO_OF_TEAMS
          valueFrom:
            configMapKeyRef:
              name: flask-app-cm
              key: number_of_teams
        envFrom:
        # Secret 'key' names are used as ENV variables names, we cannot use explicit name variable like in "env" option.
        - secretRef:
            name: flask-app-secret

        volumeMounts:
        - name: db-volume
          mountPath: /usr/src/database
        - name: secret-volume
          mountPath: /usr/src/secret
      volumes:
      - name: db-volume
        # emptyDir: {}
        persistentVolumeClaim:
          claimName: pvc-nfs-static 
      - name: secret-volume
        secret:
          secretName: flask-app-secret
      dnsPolicy: ClusterFirst

