---
# ============================================================================
# Auth Service Deployment
# ============================================================================
apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-service
  namespace: undateable
  labels:
    app.kubernetes.io/name: auth-service
    app.kubernetes.io/component: backend
    app.kubernetes.io/part-of: undateable
spec:
  replicas: 1
  selector:
    matchLabels:
      app: auth-service
  template:
    metadata:
      labels:
        app: auth-service
        app.kubernetes.io/name: auth-service
    spec:
      imagePullSecrets:
        - name: ocir-secret
      containers:
        - name: auth-service
          image: auth-service:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8001
              protocol: TCP
          envFrom:
            - configMapRef:
                name: app-config
            - secretRef:
                name: db-credentials
            - secretRef:
                name: jwt-secret
          env:
            - name: SERVICE_NAME
              value: "auth-service"
            - name: SERVICE_PORT
              value: "8001"
          resources:
            requests:
              cpu: "100m"
              memory: "256Mi"
            limits:
              cpu: "500m"
              memory: "512Mi"
          livenessProbe:
            httpGet:
              path: /health
              port: 8001
            initialDelaySeconds: 30
            periodSeconds: 10
            timeoutSeconds: 5
          readinessProbe:
            httpGet:
              path: /health
              port: 8001
            initialDelaySeconds: 5
            periodSeconds: 5
            timeoutSeconds: 3
---
# ============================================================================
# Profiles Service Deployment
# ============================================================================
apiVersion: apps/v1
kind: Deployment
metadata:
  name: profiles-service
  namespace: undateable
  labels:
    app.kubernetes.io/name: profiles-service
    app.kubernetes.io/component: backend
    app.kubernetes.io/part-of: undateable
spec:
  replicas: 1
  selector:
    matchLabels:
      app: profiles-service
  template:
    metadata:
      labels:
        app: profiles-service
        app.kubernetes.io/name: profiles-service
    spec:
      imagePullSecrets:
        - name: ocir-secret
      containers:
        - name: profiles-service
          image: profiles-service:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8002
              protocol: TCP
          envFrom:
            - configMapRef:
                name: app-config
            - secretRef:
                name: db-credentials
            - secretRef:
                name: jwt-secret
          env:
            - name: SERVICE_NAME
              value: "profiles-service"
            - name: SERVICE_PORT
              value: "8002"
          resources:
            requests:
              cpu: "200m"
              memory: "512Mi"
            limits:
              cpu: "1000m"
              memory: "1Gi"
          livenessProbe:
            httpGet:
              path: /health
              port: 8002
            initialDelaySeconds: 30
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /health
              port: 8002
            initialDelaySeconds: 5
            periodSeconds: 5
---
# ============================================================================
# Messaging Service Deployment
# ============================================================================
apiVersion: apps/v1
kind: Deployment
metadata:
  name: messaging-service
  namespace: undateable
  labels:
    app.kubernetes.io/name: messaging-service
    app.kubernetes.io/component: backend
    app.kubernetes.io/part-of: undateable
spec:
  replicas: 1
  selector:
    matchLabels:
      app: messaging-service
  template:
    metadata:
      labels:
        app: messaging-service
        app.kubernetes.io/name: messaging-service
    spec:
      imagePullSecrets:
        - name: ocir-secret
      containers:
        - name: messaging-service
          image: messaging-service:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8003
              protocol: TCP
          envFrom:
            - configMapRef:
                name: app-config
            - secretRef:
                name: db-credentials
            - secretRef:
                name: jwt-secret
          env:
            - name: SERVICE_NAME
              value: "messaging-service"
            - name: SERVICE_PORT
              value: "8003"
          resources:
            requests:
              cpu: "100m"
              memory: "256Mi"
            limits:
              cpu: "500m"
              memory: "512Mi"
          livenessProbe:
            httpGet:
              path: /health
              port: 8003
            initialDelaySeconds: 30
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /health
              port: 8003
            initialDelaySeconds: 5
            periodSeconds: 5
---
# ============================================================================
# Burn Service Deployment
# ============================================================================
apiVersion: apps/v1
kind: Deployment
metadata:
  name: burn-service
  namespace: undateable
  labels:
    app.kubernetes.io/name: burn-service
    app.kubernetes.io/component: backend
    app.kubernetes.io/part-of: undateable
spec:
  replicas: 1
  selector:
    matchLabels:
      app: burn-service
  template:
    metadata:
      labels:
        app: burn-service
        app.kubernetes.io/name: burn-service
    spec:
      imagePullSecrets:
        - name: ocir-secret
      containers:
        - name: burn-service
          image: burn-service:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8004
              protocol: TCP
          envFrom:
            - configMapRef:
                name: app-config
            - secretRef:
                name: db-credentials
            - secretRef:
                name: jwt-secret
          env:
            - name: SERVICE_NAME
              value: "burn-service"
            - name: SERVICE_PORT
              value: "8004"
          resources:
            requests:
              cpu: "100m"
              memory: "256Mi"
            limits:
              cpu: "500m"
              memory: "512Mi"
          livenessProbe:
            httpGet:
              path: /health
              port: 8004
            initialDelaySeconds: 30
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /health
              port: 8004
            initialDelaySeconds: 5
            periodSeconds: 5
---
# ============================================================================
# WebSocket Service Deployment
# ============================================================================
apiVersion: apps/v1
kind: Deployment
metadata:
  name: websocket-service
  namespace: undateable
  labels:
    app.kubernetes.io/name: websocket-service
    app.kubernetes.io/component: backend
    app.kubernetes.io/part-of: undateable
spec:
  replicas: 1
  selector:
    matchLabels:
      app: websocket-service
  template:
    metadata:
      labels:
        app: websocket-service
        app.kubernetes.io/name: websocket-service
    spec:
      imagePullSecrets:
        - name: ocir-secret
      containers:
        - name: websocket-service
          image: websocket-service:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8005
              protocol: TCP
          envFrom:
            - configMapRef:
                name: app-config
            - secretRef:
                name: db-credentials
            - secretRef:
                name: jwt-secret
            - secretRef:
                name: redis-credentials
          env:
            - name: SERVICE_NAME
              value: "websocket-service"
            - name: SERVICE_PORT
              value: "8005"
            - name: WS_PORT
              value: "8005"
            - name: NODE_ENV
              value: "production"
          resources:
            requests:
              cpu: "100m"
              memory: "256Mi"
            limits:
              cpu: "500m"
              memory: "512Mi"
          livenessProbe:
            httpGet:
              path: /health
              port: 8005
            initialDelaySeconds: 30
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /health
              port: 8005
            initialDelaySeconds: 5
            periodSeconds: 5
---
# ============================================================================
# Frontend Service Deployment (undateable.me)
# ============================================================================
apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend-service
  namespace: undateable
  labels:
    app.kubernetes.io/name: frontend-service
    app.kubernetes.io/component: frontend
    app.kubernetes.io/part-of: undateable
spec:
  replicas: 1
  selector:
    matchLabels:
      app: frontend-service
  template:
    metadata:
      labels:
        app: frontend-service
        app.kubernetes.io/name: frontend-service
    spec:
      imagePullSecrets:
        - name: ocir-secret
      containers:
        - name: frontend-service
          image: frontend-service:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 80
              protocol: TCP
          envFrom:
            - configMapRef:
                name: app-config
            - secretRef:
                name: db-credentials
            - secretRef:
                name: jwt-secret
          env:
            - name: SERVICE_NAME
              value: "frontend-service"
            - name: SERVICE_PORT
              value: "80"
          resources:
            requests:
              cpu: "200m"
              memory: "512Mi"
            limits:
              cpu: "1000m"
              memory: "1Gi"
          livenessProbe:
            httpGet:
              path: /login.php
              port: 80
            initialDelaySeconds: 30
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /login.php
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 5
---
# ============================================================================
# BurnYourEx Frontend Deployment
# ============================================================================
apiVersion: apps/v1
kind: Deployment
metadata:
  name: burnyourex-frontend
  namespace: undateable
  labels:
    app.kubernetes.io/name: burnyourex-frontend
    app.kubernetes.io/component: frontend
    app.kubernetes.io/part-of: undateable
spec:
  replicas: 1
  selector:
    matchLabels:
      app: burnyourex-frontend
  template:
    metadata:
      labels:
        app: burnyourex-frontend
        app.kubernetes.io/name: burnyourex-frontend
    spec:
      imagePullSecrets:
        - name: ocir-secret
      containers:
        - name: burnyourex-frontend
          image: burnyourex-frontend:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 80
              protocol: TCP
          env:
            - name: SERVICE_NAME
              value: "burnyourex-frontend"
            - name: SERVICE_PORT
              value: "80"
          resources:
            requests:
              cpu: "100m"
              memory: "256Mi"
            limits:
              cpu: "500m"
              memory: "512Mi"
          livenessProbe:
            httpGet:
              path: /health
              port: 80
            initialDelaySeconds: 30
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /health
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 5
