---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: logmower-eventsource
spec:
  revisionHistoryLimit: 0
  replicas: 2
  selector:
    matchLabels: &selectorLabels
      app.kubernetes.io/name: camtiler
      component: logmower-eventsource
  template:
    metadata:
      labels: *selectorLabels
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app.kubernetes.io/name
                    operator: In
                    values:
                      - camtiler
                  - key: component
                    operator: In
                    values:
                      - logmower-eventsource
              topologyKey: topology.kubernetes.io/zone
      nodeSelector:
        dedicated: storage
      tolerations:
        - key: dedicated
          operator: Equal
          value: storage
          effect: NoSchedule
      containers:
        - name: logmower-eventsource
          image: harbor.k-space.ee/k-space/logmower-eventsource
          ports:
            - containerPort: 3002
              name: nodejs
          env:
            - name: MONGO_COLLECTION
              value: eventlog
            - name: MONGODB_HOST
              valueFrom:
                secretKeyRef:
                  name: mongodb-application-readonly
                  key: connectionString.standard
            - name: BACKEND
              value: 'camtiler'
            - name: BACKEND_BROKER_URL
              value: 'http://logmower-event-broker'
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: logmower-event-broker
spec:
  revisionHistoryLimit: 0
  replicas: 2
  selector:
    matchLabels: &selectorLabels
      app.kubernetes.io/name: camtiler
      component: logmower-event-broker
  template:
    metadata:
      labels: *selectorLabels
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app.kubernetes.io/name
                    operator: In
                    values:
                      - camtiler
                  - key: component
                    operator: In
                    values:
                      - logmower-event-broker
              topologyKey: topology.kubernetes.io/zone
      nodeSelector:
        dedicated: storage
      tolerations:
        - key: dedicated
          operator: Equal
          value: storage
          effect: NoSchedule
      containers:
        - name: logmower-event-broker
          image: harbor.k-space.ee/k-space/camera-event-broker
          ports:
            - containerPort: 3000
          env:
            - name: MINIO_BUCKET
              valueFrom:
                secretKeyRef:
                  name: miniobucket-camtiler-owner-secrets
                  key: BUCKET_NAME
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  name: miniobucket-camtiler-owner-secrets
                  key: AWS_SECRET_ACCESS_KEY
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: miniobucket-camtiler-owner-secrets
                  key: AWS_ACCESS_KEY_ID
            - name: MINIO_HOSTNAME
              value: 'dedicated-5ee6428f-4cb5-4c2e-90b5-364668f515c2.minio-clusters.k-space.ee'
            - name: MINIO_PORT
              value: '443'
            - name: MINIO_SCHEMA
              value: 'https'
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: logmower-frontend
spec:
  revisionHistoryLimit: 0
  replicas: 2
  selector:
    matchLabels: &selectorLabels
      app.kubernetes.io/name: camtiler
      component: logmower-frontend
  template:
    metadata:
      labels: *selectorLabels
    spec:
      containers:
        - name: logmower-frontend
          image: harbor.k-space.ee/k-space/logmower-frontend
          ports:
            - containerPort: 8080
              name: http

---
apiVersion: v1
kind: Service
metadata:
  name: logmower-frontend
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: camtiler
    component: logmower-frontend
  ports:
    - protocol: TCP
      port: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: logmower-eventsource
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: camtiler
    component: logmower-eventsource
  ports:
    - protocol: TCP
      port: 3002
---
apiVersion: v1
kind: Service
metadata:
  name: logmower-event-broker
spec:
  type: ClusterIP
  selector:
      app.kubernetes.io/name: camtiler
      component: logmower-event-broker
  ports:
    - protocol: TCP
      port: 80
      targetPort: 3000