apiVersion: apps/v1
kind: Deployment
metadata:
  name: logseq
  namespace: home-apps
  labels:
    app: logseq
spec:
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: logseq
  template:
    metadata:
      labels:
        app: logseq
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/hostname
                    operator: In
                    values:
                      - server-3
      containers:
        - name: logseq
          image: ghcr.io/logseq/logseq-webapp:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 80
              name: web
              protocol: TCP
          resources:
            requests:
              memory: "64Mi"
              cpu: "100m"
            limits:
              memory: "400Mi"
              cpu: "400m"
---
apiVersion: v1
kind: Service
metadata:
  name: logseq
  namespace: home-apps
  labels:
    app: logseq
spec:
  selector:
    app: logseq
  ports:
    - name: web
      port: 80
      targetPort: 80
      protocol: TCP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: logseq-ingress
  namespace: home-apps
  annotations:
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    # HTTPS required by File System Access API used by Logseq web app
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
    nginx.ingress.kubernetes.io/auth-url: "https://pass.junv.cc/oauth2/auth"
    nginx.ingress.kubernetes.io/auth-signin: "https://pass.junv.cc/oauth2/start?rd=https://$host$escaped_request_uri"
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - logseq.junv.cc
      secretName: logseq-tls
  rules:
    - host: logseq.junv.cc
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: logseq
                port:
                  number: 80
