---
# Notification Service Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: notification-service
  namespace: hgzero
  labels:
    app: notification-service
    tier: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: notification-service
  template:
    metadata:
      labels:
        app: notification-service
        tier: backend
    spec:
      containers:
      - name: notification-service
        image: acrdigitalgarage02.azurecr.io/hgzero/notification-service:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8082
          name: http
        env:
        - name: SPRING_PROFILES_ACTIVE
          value: "prod"
        - name: SERVER_PORT
          value: "8082"
        - name: DB_HOST
          valueFrom:
            secretKeyRef:
              name: db-secret
              key: host
        - name: DB_USERNAME
          valueFrom:
            secretKeyRef:
              name: db-secret
              key: username
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: db-secret
              key: password
        - name: REDIS_HOST
          valueFrom:
            configMapKeyRef:
              name: redis-config
              key: host
        - name: REDIS_PORT
          valueFrom:
            configMapKeyRef:
              name: redis-config
              key: port
        - name: AZURE_EVENTHUB_CONNECTION_STRING
          valueFrom:
            secretKeyRef:
              name: azure-secret
              key: eventhub-connection-string
        - name: AZURE_BLOB_CONNECTION_STRING
          valueFrom:
            secretKeyRef:
              name: azure-secret
              key: blob-connection-string
        - name: MAIL_HOST
          valueFrom:
            configMapKeyRef:
              name: mail-config
              key: host
        - name: MAIL_PORT
          valueFrom:
            configMapKeyRef:
              name: mail-config
              key: port
        - name: MAIL_USERNAME
          valueFrom:
            secretKeyRef:
              name: mail-secret
              key: username
        - name: MAIL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mail-secret
              key: password
        resources:
          requests:
            cpu: 256m
            memory: 256Mi
          limits:
            cpu: 1024m
            memory: 1024Mi
        livenessProbe:
          httpGet:
            path: /actuator/health/liveness
            port: 8082
          initialDelaySeconds: 60
          periodSeconds: 10
          timeoutSeconds: 5
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /actuator/health/readiness
            port: 8082
          initialDelaySeconds: 30
          periodSeconds: 5
          timeoutSeconds: 3
          failureThreshold: 3
---
# Notification Service Service
apiVersion: v1
kind: Service
metadata:
  name: notification-service
  namespace: hgzero
  labels:
    app: notification-service
spec:
  type: ClusterIP
  ports:
  - port: 8082
    targetPort: 8082
    protocol: TCP
    name: http
  selector:
    app: notification-service
