---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: restic-robot
  labels:
    app.kubernetes.io/name: restic-robot
    app.kubernetes.io/component: backup
  namespace: storage-system
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: restic-robot
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: restic-robot
        app.kubernetes.io/component: backup
    spec:
      containers:
      - name: restic
        image: quay.io/paulfantom/restic-robot:latest
        ports:
          - name: metrics
            containerPort: 8080
        env:
          - name: RESTIC_ARGS
            value: "/backup"
          - name: SCHEDULE
            value: "17 2 * * *"  # At 01:17
          - name: PRE_COMMAND
            value: "restic unlock"
          - name: POST_COMMAND
            value: "restic forget --keep-last 14 --keep-daily 7 --keep-monthly 6 --keep-yearly 2"
        envFrom:
          - secretRef:
              name: restic-repository
        volumeMounts:
          - mountPath: /backup
            name: content
            readOnly: true
        resources:
          requests:
            memory: 420Mi
            cpu: 2m
          limits:
            memory: 800Mi
            cpu: 40m
      nodeName: metal01
      volumes:
        - name: content
          hostPath:
            path: "/srv/storage/kubernetes/nfs-dynamic"
            type: Directory
