---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: cloudreve-ingress
  annotations:
    cert-manager.io/cluster-issuer: "cm-cf"
    kubernetes.io/ingress.class: "traefik"
spec:
  rules:
    - host: pan.s0.107421.xyz
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: cloudreve-svc
                port:
                  number: 5212
  tls:
    - hosts:
        - pan.s0.107421.xyz
      secretName: pan.s0.107421.xyz-tls
---
kind: Service
apiVersion: v1
metadata:
  name: cloudreve-svc
  namespace: default
spec:
  selector:
    app: cloudreve-3.4.2
  type: ClusterIP
  ports:
    - port: 5212
      targetPort: 5212
      name: http

---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: cloudreve-3.4.2
  namespace: default
spec:
  selector:
    matchLabels:
      app: cloudreve-3.4.2
  replicas: 1
  template:
    metadata:
      labels:
        app: cloudreve-3.4.2
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/hostname
                    operator: In
                    values:
                      - master-s0
      restartPolicy: Always
      containers:
        - name: cloudreve
          image: xavierniu/cloudreve:3.4.2
          imagePullPolicy: IfNotPresent
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: PUID
              value: '5001'
            - name: PGID
              value: '5001'
          volumeMounts:
            - mountPath: /cloudreve/uploads
              subPath: uploads
              name: cloudreve-pv-data
            - mountPath: /cloudreve/config
              subPath: config
              name: cloudreve-pv-data
            - mountPath: /cloudreve/db
              subPath: db
              name: cloudreve-pv-data
            - mountPath: /cloudreve/avatar
              subPath: avatar
              name: cloudreve-pv-data
            - mountPath: /cloudreve/aria2-downloads
              subPath: aria2-downloads
              name: cloudreve-pv-data
          ports:
            - containerPort: 5212
              name: http
      volumes:
        - name: cloudreve-pv-data
          persistentVolumeClaim:
            claimName: cloudreve-pvc
