apiVersion: apps/v1
kind: Deployment
metadata:
  name: sankofa-frontend
  namespace: sankofa
  labels:
    app: sankofa-frontend
spec:
  replicas: 2
  selector:
    matchLabels:
      app: sankofa-frontend
  template:
    metadata:
      labels:
        app: sankofa-frontend
    spec:
      containers:
      - name: frontend
        image: sankofa-frontend:latest
        ports:
        - containerPort: 3000
          name: http
        env:
        - name: NEXT_PUBLIC_GRAPHQL_ENDPOINT
          valueFrom:
            configMapKeyRef:
              name: sankofa-frontend-config
              key: graphql-endpoint
        - name: NODE_ENV
          value: "production"
        resources:
          requests:
            cpu: 250m
            memory: 256Mi
          limits:
            cpu: 1000m
            memory: 1Gi
        livenessProbe:
          httpGet:
            path: /api/health
            port: 3000
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /api/health
            port: 3000
          initialDelaySeconds: 10
          periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: sankofa-frontend
  namespace: sankofa
  labels:
    app: sankofa-frontend
spec:
  type: ClusterIP
  ports:
  - port: 3000
    targetPort: 3000
    protocol: TCP
    name: http
  selector:
    app: sankofa-frontend
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sankofa-frontend
  namespace: sankofa
spec:
  rules:
  - host: sankofa.local
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: sankofa-frontend
            port:
              number: 3000

