apiVersion: apps/v1
kind: Deployment
metadata:
  name: sankofa-api
  namespace: sankofa
  labels:
    app: sankofa-api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: sankofa-api
  template:
    metadata:
      labels:
        app: sankofa-api
    spec:
      containers:
      - name: api
        image: sankofa-api:latest
        ports:
        - containerPort: 4000
          name: http
        env:
        - name: DB_HOST
          valueFrom:
            secretKeyRef:
              name: sankofa-db-credentials
              key: host
        - name: DB_PORT
          value: "5432"
        - name: DB_NAME
          valueFrom:
            secretKeyRef:
              name: sankofa-db-credentials
              key: database
        - name: DB_USER
          valueFrom:
            secretKeyRef:
              name: sankofa-db-credentials
              key: username
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: sankofa-db-credentials
              key: password
        - name: JWT_SECRET
          valueFrom:
            secretKeyRef:
              name: sankofa-api-secrets
              key: jwt-secret
        - name: NODE_ENV
          value: "production"
        resources:
          requests:
            cpu: 500m
            memory: 512Mi
          limits:
            cpu: 2000m
            memory: 2Gi
        livenessProbe:
          httpGet:
            path: /health
            port: 4000
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /health
            port: 4000
          initialDelaySeconds: 10
          periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: sankofa-api
  namespace: sankofa
  labels:
    app: sankofa-api
spec:
  type: ClusterIP
  ports:
  - port: 4000
    targetPort: 4000
    protocol: TCP
    name: http
  selector:
    app: sankofa-api

