{{- if and .Values.ingress .Values.ingress.marketplace .Values.ingress.marketplace.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: notification
  namespace: sme
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sme-notification
  template:
    metadata:
      labels:
        app: sme-notification
    spec:
      imagePullSecrets:
        - name: ghcr-pull
      containers:
        - name: notification
          image: "{{ if .Values.global.imageRegistry }}{{ .Values.global.imageRegistry }}{{ else }}{{ .Values.images.registry }}{{ end }}/{{ .Values.images.organization }}/services-notification:{{ .Values.images.smeTag }}"
          imagePullPolicy: Always
          ports:
            - containerPort: 8087
          env:
            - name: REDPANDA_BROKERS
              value: "redpanda.talentmesh.svc.cluster.local:9092"
            - name: JWT_SECRET
              valueFrom:
                secretKeyRef:
                  name: sme-secrets
                  key: JWT_SECRET
            - name: SMTP_HOST
              valueFrom:
                secretKeyRef:
                  name: sme-secrets
                  key: SMTP_HOST
            - name: SMTP_PORT
              valueFrom:
                secretKeyRef:
                  name: sme-secrets
                  key: SMTP_PORT
            - name: SMTP_FROM
              valueFrom:
                secretKeyRef:
                  name: sme-secrets
                  key: SMTP_FROM
            - name: CORS_ORIGIN
              value: "https://sme.openova.io"
          resources:
            requests:
              cpu: 25m
              memory: 32Mi
            limits:
              cpu: 500m
              memory: 128Mi
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8087
            initialDelaySeconds: 5
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8087
            initialDelaySeconds: 3
            periodSeconds: 5
          securityContext:
            allowPrivilegeEscalation: false
            runAsNonRoot: true
            runAsUser: 65534
---
apiVersion: v1
kind: Service
metadata:
  name: notification
  namespace: sme
spec:
  selector:
    app: sme-notification
  ports:
    - port: 8087
      targetPort: 8087
{{- end }}
