apiVersion: apps/v1
kind: Deployment
metadata:
  name: logs-api
  namespace: josie-health
spec:
  replicas: 1
  selector:
    matchLabels:
      app: logs-api
  template:
    metadata:
      labels:
        app: logs-api
    spec:
      containers:
      - name: logs-api
        image: image-registry.openshift-image-registry.svc:5000/josie-health/simple-logs-api:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 3001
        env:
        - name: API_USERNAME
          value: "admin"
        - name: API_PASSWORD
          valueFrom:
            secretKeyRef:
              name: josie-health-secrets
              key: GRAFANA_ADMIN_PASSWORD  # Reuse same password for simplicity
        - name: KEMAL_ENV
          value: "production"
        resources:
          requests:
            memory: "128Mi"
            cpu: "50m"
          limits:
            memory: "256Mi"
            cpu: "100m"
---
apiVersion: v1
kind: Service
metadata:
  name: logs-api
  namespace: josie-health
spec:
  selector:
    app: logs-api
  ports:
  - port: 3001
    targetPort: 3001
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  name: logs-api-route
  namespace: josie-health
spec:
  host: logs.josie.health
  to:
    kind: Service
    name: logs-api
  port:
    targetPort: 3001
  tls:
    termination: edge