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

apiVersion: apps/v1
kind: Deployment
metadata:
  name: langflow
  namespace: ai
  labels:
    app: langflow
spec:
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: langflow
  template:
    metadata:
      labels:
        app: langflow
        name: langflow
    spec:
      containers:
        - name: langflow
          image: mirror.gcr.io/langflowai/langflow:1.3.4
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 7860
              name: web
              protocol: TCP
          env:
            - name: GENERIC_TIMEZONE
              value: "Australia/Melbourne"
            - name: TZ
              value: "Australia/Melbourne"
            - name: LANGFLOW_CONFIG_DIR
              value: "/var/lib/langflow"
            - name: LANGFLOW_SAVE_DB_IN_CONFIG_DIR
              value: "true"
            - name: LANGFLOW_REDIS_HOST
              value: "redis-master.db"
            - name: LANGFLOW_REDIS_PORT
              value: "6379"
            - name: LANGFLOW_CACHE_TYPE
              value: "memory"
            - name: LANGFLOW_PORT
              value: "7860"
            - name: DO_NOT_TRACK
              value: "true"
          volumeMounts:
            - name: data
              mountPath: "/var/lib/langflow"
          resources:
            requests:
              cpu: 400m
              memory: 1Gi
            limits:
              cpu: 1000m
              memory: 2Gi
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: langflow-pvc

---

apiVersion: v1
kind: Service
metadata:
  name: langflow
  labels:
    name: langflow
spec:
  type: ClusterIP
  selector:
    app: langflow
  ports:
    - name: langflow
      targetPort: web
      port: 80
      protocol: TCP

---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: langflow-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:
    - langflow.junv.cc
    secretName: langflow-tls-new
  rules:
  - host: langflow.junv.cc
    http:
      paths:
      - backend:
          service:
            name: langflow
            port:
              number: 80
        path: /
        pathType: Prefix
