---
# PVC for persistent reminder storage
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: reminder-service-pvc
  namespace: ai-agents
spec:
  accessModes: [ReadWriteOnce]
  storageClassName: longhorn
  resources:
    requests:
      storage: 512Mi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: reminder-service
  namespace: ai-agents
  labels:
    app: reminder-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: reminder-service
  template:
    metadata:
      labels:
        app: reminder-service
    spec:
      initContainers:
        - name: git-clone
          image: alpine/git
          command:
            - git
            - clone
            - http://192.168.8.248:3000/deepkoluguri/agentic-os.git
            - /app
          volumeMounts:
            - name: app-volume
              mountPath: /app
      containers:
        - name: reminder-service
          image: node:18-alpine
          workingDir: /app/reminder-service
          command:
            - sh
            - -c
            - npm install --omit=dev && node server.js
          ports:
            - containerPort: 6001
          env:
            - name: DATA_FILE
              value: /data/reminders.json
            - name: PORT
              value: "6001"
            - name: GATEWAY_URL
              value: http://whatsapp-gateway.ai-agents.svc.cluster.local:5001/send-message
            - name: PERSONAL_NUM
              value: "+14085505485"
            - name: GROUP_URL
              valueFrom:
                configMapKeyRef:
                  name: whatsapp-config
                  key: default-group-url
          volumeMounts:
            - name: app-volume
              mountPath: /app
            - name: data-volume
              mountPath: /data
          resources:
            requests:
              cpu: 50m
              memory: 128Mi
            limits:
              cpu: 200m
              memory: 256Mi
          readinessProbe:
            httpGet:
              path: /health
              port: 6001
            initialDelaySeconds: 30
            periodSeconds: 15
      volumes:
        - name: app-volume
          emptyDir: {}
        - name: data-volume
          persistentVolumeClaim:
            claimName: reminder-service-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: reminder-service
  namespace: ai-agents
spec:
  selector:
    app: reminder-service
  ports:
    - port: 6001
      targetPort: 6001
