apiVersion: apps/v1
kind: Deployment
metadata:
  name: gateway
  namespace: bakery-ia
  labels:
    app.kubernetes.io/name: gateway
    app.kubernetes.io/component: gateway
    app.kubernetes.io/part-of: bakery-ia
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: gateway
      app.kubernetes.io/component: gateway
  template:
    metadata:
      labels:
        app.kubernetes.io/name: gateway
        app.kubernetes.io/component: gateway
    spec:
      containers:
      - name: gateway
        image: bakery/gateway:latest
        ports:
        - containerPort: 8000
          name: http
        envFrom:
        - configMapRef:
            name: bakery-config
        - secretRef:
            name: database-secrets
        - secretRef:
            name: redis-secrets
        - secretRef:
            name: rabbitmq-secrets
        - secretRef:
            name: jwt-secrets
        - secretRef:
            name: external-api-secrets
        - secretRef:
            name: payment-secrets
        - secretRef:
            name: email-secrets
        - secretRef:
            name: monitoring-secrets
        - secretRef:
            name: pos-integration-secrets
        - secretRef:
            name: whatsapp-secrets
        resources:
          requests:
            memory: "256Mi"
            cpu: "100m"
          limits:
            memory: "512Mi"
            cpu: "500m"
        livenessProbe:
          httpGet:
            path: /health
            port: 8000
          initialDelaySeconds: 30
          timeoutSeconds: 10
          periodSeconds: 30
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /health
            port: 8000
          initialDelaySeconds: 5
          timeoutSeconds: 5
          periodSeconds: 10
          failureThreshold: 3

---
apiVersion: v1
kind: Service
metadata:
  name: gateway-service
  namespace: bakery-ia
  labels:
    app.kubernetes.io/name: gateway
    app.kubernetes.io/component: gateway
spec:
  type: ClusterIP
  ports:
  - port: 8000
    targetPort: 8000
    protocol: TCP
    name: http
  selector:
    app.kubernetes.io/name: gateway
    app.kubernetes.io/component: gateway
