apiVersion: apps/v1
kind: Deployment
metadata:
  name: utility-agent
  namespace: ai-agents
spec:
  replicas: 1
  selector:
    matchLabels:
      app: utility-agent
  template:
    metadata:
      labels:
        app: utility-agent
    spec:
      initContainers:
      - name: git-clone
        image: alpine/git
        command:
        - /bin/sh
        - -c
        - "git clone http://192.168.8.248:3000/deepkoluguri/agentic-os.git /app"
        volumeMounts:
        - name: app-volume
          mountPath: /app
      - name: chown-permissions
        image: alpine
        command:
        - /bin/sh
        - -c
        - "chmod -R 777 /app && chmod -R 777 /secrets"
        volumeMounts:
        - name: app-volume
          mountPath: /app
        - name: utility-secrets
          mountPath: /secrets
      containers:
      - name: utility-agent
        # We use a custom puppeteer-compatible image or just build one.
        # But wait, in the agentic-os system, the pods usually just run `python` or `node`.
        # Since Puppeteer requires chrome, we'll assume the registry has built it or we just build it.
        # For this PoC, we will use a pre-built node image that has puppeteer deps or just build it locally.
        # Wait, the Talos cluster might not build it. I'll just use the Dockerfile to build it if I have to,
        # but since I don't have a registry here to push it, let's use `ghcr.io/puppeteer/puppeteer:latest`.
        image: ghcr.io/puppeteer/puppeteer:latest
        command: ["sh", "-c", "cd /app/utility-agent && npm install && npm start"]
        ports:
        - containerPort: 5005
        volumeMounts:
        - name: app-volume
          mountPath: /app
        - name: utility-secrets
          mountPath: /app/utility-agent/.secrets
      volumes:
      - name: app-volume
        emptyDir: {}
      - name: utility-secrets
        persistentVolumeClaim:
          claimName: utility-secrets-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: utility-secrets-pvc
  namespace: ai-agents
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Mi
---
apiVersion: v1
kind: Service
metadata:
  name: utility-agent
  namespace: ai-agents
spec:
  selector:
    app: utility-agent
  ports:
    - protocol: TCP
      port: 5005
      targetPort: 5005
