# Velero Full Installation
# 來源: velero install --dry-run -o yaml
# 建立者: Claude Code (首席架構師)
# 日期: 2026-03-28 (台北時間)

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: velero
  namespace: velero
  labels:
    component: velero

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: velero
  labels:
    component: velero
subjects:
  - kind: ServiceAccount
    name: velero
    namespace: velero
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin

---
apiVersion: velero.io/v1
kind: BackupStorageLocation
metadata:
  name: default
  namespace: velero
spec:
  provider: aws
  objectStorage:
    bucket: velero-backups
  config:
    region: minio
    s3ForcePathStyle: "true"
    s3Url: http://192.168.0.188:9000

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: velero
  namespace: velero
  labels:
    component: velero
spec:
  replicas: 1
  selector:
    matchLabels:
      component: velero
  template:
    metadata:
      labels:
        component: velero
    spec:
      serviceAccountName: velero
      containers:
        - name: velero
          image: velero/velero:v1.13.0
          imagePullPolicy: IfNotPresent
          ports:
            - name: metrics
              containerPort: 8085
          command:
            - /velero
          args:
            - server
            - --features=
          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
          volumeMounts:
            - name: plugins
              mountPath: /plugins
            - name: scratch
              mountPath: /scratch
            - name: cloud-credentials
              mountPath: /credentials
          resources:
            requests:
              cpu: 500m
              memory: 128Mi
            limits:
              cpu: 1000m
              memory: 512Mi
      initContainers:
        - name: velero-plugin-for-aws
          image: velero/velero-plugin-for-aws:v1.9.0
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: plugins
              mountPath: /target
      volumes:
        - name: cloud-credentials
          secret:
            secretName: velero-minio-credentials
        - name: plugins
          emptyDir: {}
        - name: scratch
          emptyDir: {}
      restartPolicy: Always
