apiVersion: apps/v1
kind: Deployment
metadata:
  name: scraang-deployment
  namespace: default
  labels:
    app: scraang
    tier: frontend
    environment: production
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: scraang
      environment: production
  template:
    metadata:
      labels:
        app: scraang
        tier: frontend
        environment: production
    spec:
      restartPolicy: Always    
      containers:
      - name: scraper
        image: nliakm/scraang-scraper:latest
        imagePullPolicy: Always
        volumeMounts:
          - mountPath: /var/offers
            name: www
            subPath: files
        env:
          - name: HOUR
            value: "23"
          - name: MIN
            value: "59"
          - name: MARKETNAMES
            value: "REWE,Penny-Markt,EDEKA"
          - name: LATITUDE
            valueFrom:
              secretKeyRef:
                name: default-secrets
                key: SCRAANG_LAT
          - name: LONGITUDE
            valueFrom:
              secretKeyRef:
                name: default-secrets
                key: SCRAANG_LON
      - name: flask
        image: nliakm/scraang-flask:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 5000
          protocol: TCP
          name: http        
        volumeMounts:
          - mountPath: /var/offers
            name: www
            subPath: files
        env:
          - name: HASS_URL
            value: "hass.${SECRET_DOMAIN}"
          - name: HASS_BEARER_TOKEN
            valueFrom:
              secretKeyRef:
                name: default-secrets
                key: HASS_BEARER_TOKEN            
        livenessProbe:
          failureThreshold: 5
          httpGet:
            path: /
            port: 5000
            scheme: HTTP
          periodSeconds: 30
        readinessProbe:
          httpGet:
            path: /
            port: 5000
            scheme: HTTP
          periodSeconds: 30        
      volumes:
        - name: www
          persistentVolumeClaim:
            claimName: scraang-www
       