# Copyright (c) 2020 SIGHUP s.r.l All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    k8s-app: velero-restic
  name: velero-restic
spec:
  selector:
    matchLabels:
      k8s-app: velero-restic
  template:
    metadata:
      labels:
        k8s-app: velero-restic
    spec:
      containers:
      - args:
        - restic
        - server
        command:
        - /velero
        env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: VELERO_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: VELERO_SCRATCH_DIR
          value: /scratch
        - name: AZURE_CREDENTIALS_FILE
          value: /credentials/cloud
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: /credentials/cloud
        - name: AWS_SHARED_CREDENTIALS_FILE
          value: /credentials/cloud
        image: velero/velero
        imagePullPolicy: Always
        securityContext:
          allowPrivilegeEscalation: false
        name: restic
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - mountPath: /host_pods
          mountPropagation: HostToContainer
          name: host-pods
        - mountPath: /scratch
          name: scratch
        - mountPath: /credentials
          name: cloud-credentials
      securityContext:
        runAsUser: 0
      serviceAccountName: velero
      volumes:
      - hostPath:
          path: /var/lib/kubelet/pods
        name: host-pods
      - emptyDir: {}
        name: scratch
      - name: cloud-credentials
        secret:
          secretName: cloud-credentials
