# # source https://github.com/lobehub/lobe-chat
# apiVersion: v1
# kind: PersistentVolumeClaim
# metadata:
#   namespace: ai
#   name: open-webui-pvc
# spec:
#   accessModes:
#     - ReadWriteOnce
#   storageClassName: nfs-client
#   resources:
#     requests:
#       storage: 10Gi
# ---

# apiVersion: v1
# kind: Service
# metadata:
#   name: open-webui
#   namespace: ai
# spec:
#   ports:
#     - port: 8080
#       targetPort: 8080
#   selector:
#     app: open-webui
# ---

# apiVersion: apps/v1
# kind: Deployment
# metadata:
#   name: open-webui
# spec:
#   revisionHistoryLimit: 2
#   selector:
#     matchLabels:
#       app: open-webui
#   replicas: 1
#   template:
#     metadata:
#       labels:
#         app: open-webui
#     spec:
#       volumes:
#         - name: data
#           persistentVolumeClaim:
#             claimName: open-webui-pvc
#       containers:
#         - name: open-webui
#           image: ghcr.io/open-webui/open-webui:main
#           # imagePullPolicy:
#           ports:
#             - containerPort: 8080
#           env:
#             - name: OPENAI_API_BASE_URL
#               value: "https://api.openai.com/v1"
#             - name: OPENAI_API_KEY
#               valueFrom:
#                 secretKeyRef:
#                   name: openai-key
#                   key: key
#             - name: SEARXNG_QUERY_URL
#               value: http://searxng.home-apps:8080/
#             - name: ENABLE_OLLAMA_API
#               value: "false"
#             - name: USE_OLLAMA
#               value: "false"
#             - name: USE_OLLAMA_DOCKER
#               value: "true"
#             # - name: OPENAI_API_KEY
#             #   value: "0p3n-w3bu!"
#             # - name: OPENAI_API_BASE_URL
#             #   value: "http://open-webui-pipeline.ai:9090"
#           resources:
#             requests:
#               cpu: 300m
#               memory: 512Mi
#             limits:
#               cpu: 1000m
#               memory: 1024Mi
#           volumeMounts:
#             - name: data
#               mountPath: /app/backend/data


# ---
# apiVersion: networking.k8s.io/v1
# kind: Ingress
# metadata:
#   name: open-webui-ingress
#   annotations:
#     kubernetes.io/ingress.class: "nginx"
#     kubernetes.io/tls-acme: "true"
#     cert-manager.io/cluster-issuer: "letsencrypt-prod"
#     nginx.ingress.kubernetes.io/auth-url: "https://id.junv.cc/oauth2/auth"
#     nginx.ingress.kubernetes.io/auth-signin: "https://id.junv.cc/oauth2/start?rd=https%3A%2F%2F$host$request_uri"
# spec:
#   tls:
#     - hosts:
#         - ai.junv.cc
#       secretName: open-webui-tls
#   rules:
#     - host: ai.junv.cc
#       http:
#         paths:
#           - backend:
#               service:
#                 name: open-webui
#                 port:
#                   number: 8080
#             path: /
#             pathType: Prefix

# ---
# apiVersion: v1
# kind: Service
# metadata:
#   name: open-webui-pipeline
#   namespace: ai
# spec:
#   ports:
#     - port: 9099
#       targetPort: 9099
#   selector:
#     app: open-webui-pipeline
# ---

# apiVersion: apps/v1
# kind: Deployment
# metadata:
#   name: open-webui-pipeline
# spec:
#   revisionHistoryLimit: 2
#   selector:
#     matchLabels:
#       app: open-webui-pipeline
#   replicas: 1
#   template:
#     metadata:
#       labels:
#         app: open-webui-pipeline
#     spec:
#       volumes:
#         - name: pipelines
#           persistentVolumeClaim:
#             claimName: open-webui-pipeline-pvc
#       containers:
#         - name: open-webui-pipeline
#           image: ghcr.io/open-webui/pipelines:main
#           imagePullPolicy: IfNotPresent
#           ports:
#             - containerPort: 9099
#           # env:
#           #   - name: SEARXNG_QUERY_URL
#           #     value: http://searxng.home-apps:8080/
#           resources:
#             requests:
#               cpu: 200m
#               memory: 256Mi
#             limits:
#               cpu: 1000m
#               memory: 1024Mi
#           volumeMounts:
#             - name: pipelines
#               mountPath: /app/pipelines

# ---

# apiVersion: v1
# kind: PersistentVolumeClaim
# metadata:
#   namespace: ai
#   name: open-webui-pipeline-pvc
# spec:
#   accessModes:
#     - ReadWriteOnce
#   storageClassName: nfs-client
#   resources:
#     requests:
#       storage: 10Gi
