apiVersion: apps/v1
kind: Deployment
metadata:
  name: open-webui
  namespace: interface
  labels:
    app.kubernetes.io/name: open-webui
spec:
  replicas: 1
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app.kubernetes.io/name: open-webui
  strategy:
    type: Recreate # Better for single PVCs
  template:
    metadata:
      labels:
        app.kubernetes.io/name: open-webui
    spec:
      containers:
      - name: open-webui
        # Pinning to a specific version is recommended, but keeping main if user prefers.
        # Alternatively, using a recent stable tag like v0.3.32
        image: ghcr.io/open-webui/open-webui:main
        imagePullPolicy: IfNotPresent
        env:
        - name: OLLAMA_BASE_URL
          value: "http://ollama.ai-core.svc.cluster.local:11434"
        - name: WEBUI_AUTH
          value: "False" # Based on default, keeping it simple or whatever they had
        ports:
        - containerPort: 8080
          protocol: TCP
        resources:
          requests:
            cpu: 250m
            memory: 512Mi
          limits:
            cpu: 2000m
            memory: 2Gi
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 30
          periodSeconds: 15
        readinessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 10
          periodSeconds: 5
        volumeMounts:
        - mountPath: /app/backend/data
          name: open-webui-data
      volumes:
      - name: open-webui-data
        persistentVolumeClaim:
          claimName: open-webui-pvc
