---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    component: velero
  name: velero
  namespace: velero
spec:
  selector:
    matchLabels:
      deploy: velero
  strategy: {}
  template:
    metadata:
      annotations:
        prometheus.io/path: /metrics
        prometheus.io/port: "8085"
        prometheus.io/scrape: "true"
      labels:
        component: velero
        deploy: velero
    spec:
      containers:
        - args:
            - server 
            - --log-level 
            - debug       
          command:
            - /velero
          env:
            - name: VELERO_SCRATCH_DIR
              value: /scratch
            - name: VELERO_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: LD_LIBRARY_PATH
              value: /plugins
            - name: AWS_SHARED_CREDENTIALS_FILE
              value: /credentials/cloud
            - name: AZURE_SHARED_CREDENTIALS_FILE
              value: /credentials/cloud
            - name: GOOGLE_APPLICATION_CREDENTIALS
              value: /credentials/cloud
          name: velero
          image: velero/velero
          imagePullPolicy: Always
          ports:
            - containerPort: 8085
              name: metrics
            - containerPort: 2345
              name: delve
          resources:
            limits:
              cpu: "1"
              memory: 512Mi
            requests:
              cpu: 500m
              memory: 128Mi
          volumeMounts:
            - mountPath: /scratch
              name: scratch
            - mountPath: /plugins
              name: plugins
            - mountPath: /credentials
              name: cloud-credentials
      initContainers:
        - image: velero/velero-plugin-for-aws
          imagePullPolicy: Always
          name: velero-plugin-for-aws
          volumeMounts:
          - mountPath: /target
            name: plugins
        - image: velero/velero-plugin-for-gcp
          imagePullPolicy: Always
          name: velero-plugin-for-gcp
          volumeMounts:
          - mountPath: /target
            name: plugins
        - image: velero/velero-plugin-for-microsoft-azure
          imagePullPolicy: Always
          name: velero-plugin-for-microsoft-azure
          volumeMounts:
          - mountPath: /target
            name: plugins
        - image: velero/velero-plugin-for-csi
          imagePullPolicy: Always
          name: velero-plugin-for-csi
          volumeMounts:
          - mountPath: /target
            name: plugins
      restartPolicy: Always
      serviceAccountName: velero
      volumes:
        - emptyDir: {}
          name: scratch
        - emptyDir: {}
          name: plugins
        - name: cloud-credentials
          secret:
            secretName: cloud-credentials
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  labels:
    component: velero
  name: velero
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: velero
    namespace: velero
---
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    component: velero
  name: velero
  namespace: velero
---
apiVersion: v1
kind: Namespace
metadata:
  labels:
    component: velero
  name: velero
spec: {}
