apiVersion: apps/v1
kind: Deployment
metadata:
  name: flask-app-deployment
  namespace:  {{ .Release.Namespace }}
  labels:
    app: contosowebapp
    app.kubernetes.io/name: "contosowebapp"
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    app.kubernetes.io/version: {{ .Chart.AppVersion }}
    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
spec:
  replicas: 2  
  selector:
    matchLabels:
      app: contosowebapp
  template:
    metadata:
      labels:
        app: contosowebapp
    spec:
      containers:
      - name: contosowebapp
        image: mcr.microsoft.com/jumpstart/agora/ag_mfg_webui:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 5001
        env:
        - name: OVMS_URL
          value: {{ .Values.ovmsURL }}
        - name: INFLUX_URL
          value: {{ .Values.influxdbURL }}
        - name: ADX_URL
          value: "http://default-adx-url:port"
        volumeMounts:
        - name: config-volume
          mountPath: /app/config
      volumes:
      - name: config-volume
        configMap:
          name: model-configs
          items:
          - key: config_file.json
            path: config_file.json
---
apiVersion: v1
kind: Service
metadata:
  name: flask-app-service
  namespace:  {{ .Release.Namespace }}
  labels:
    app.kubernetes.io/name: "flask-app"
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    app.kubernetes.io/version: {{ .Chart.AppVersion }}
    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
spec:
  selector:
    app: contosowebapp
  ports:
  - protocol: TCP
    port: 8888
    targetPort: 5001
  type: LoadBalancer