apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  namespace: home-apps
  name: archive-box-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: nfs-client
  resources:
    requests:
      storage: 100Gi
---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: archivebox
  namespace: home-apps
  labels:
    app: archivebox
spec:
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: archivebox
  template:
    metadata:
      labels:
        app: archivebox
        name: archivebox
    spec:
      containers:
        - name: archivebox
          image: archivebox/archivebox:0.7
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 8000
              name: web
              protocol: TCP
          env:
            - name: TZ
              value: "Australia/Melbourne"
            - name: SAVE_WGET
              value: "false"
            - name: SAVE_WARC
              value: "false"
            - name: SAVE_DOM
              value: "false"
            - name: SAVE_READABILITY
              value: "false"
            - name: SAVE_MERCURY
              value: "false"
            - name: SAVE_GIT
              value: "false"
            - name: SAVE_ARCHIVE_DOT_ORG
              value: "false"
          volumeMounts:
            - name: data
              mountPath: "/data"
          securityContext:
            privileged: false
            runAsGroup: 1000
            fsGroup: 1000
            # runAsUser: 1000
          resources:
            requests:
              cpu: 500m
              memory: 512Mi
            limits:
              cpu: 1500m
              memory: 2Gi
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: archive-box-pvc

---

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

---

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