apiVersion: v1
kind: Pod
metadata:
  #namespace: default
  name: flask-app
  labels:
    app: flask-ipl-app
spec:
  containers:
  - name: ipl-app
    image: punithmgp/flask-ipl:v1.0
    imagePullPolicy: IfNotPresent
    resources:
      limits:
        cpu: "200m"
        memory: "128Mi"
      requests:
        cpu: "100m"
        memory: "128Mi"
    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
    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
    volumeMounts:
    - name: db-volume
      mountPath: /usr/src/database
    - name: secret-volume
      mountPath: /usr/src/secret
    - name: cm-volume
      mountPath: /usr/src/cm
      subPath: cm
    ports:
    - containerPort: 5000
      name: flask-port
      # Default protocol is TCP 
      protocol: TCP

  volumes:
  - name: db-volume
    # temporary, update the volume type to pv
    # emptyDir: {}
    persistentVolumeClaim:
      claimName: pvc-nfs-static
  - name: secret-volume
    secret:
      # all the keys in the Secret are mounted as files at /usr/src/secret
      secretName: flask-app-secret
  - name: cm-volume
    configMap:
      name: flask-app-cm
      items:
      - key: number_of_teams
        # Path shall match with subPath in volumeMount otherwise no files will be created
        path: cm
  # default dnsPolicy is ClusterFirst
  dnsPolicy: ClusterFirst

