Velero - 卷快照在恢复备份时不包含任何数据

问题描述 投票:0回答:1

我想使用 Velero 将应用程序备份到 minio 存储桶。这是一些背景信息,我有 2 个 AKS 集群 [开发、工具]。

tools 集群运行我的 minio 实例,dev 是我的工作负载的集群。

我按照互联网上的一些示例,了解如何使用 helm 安装 Velero 以及如何配置它以将 worloads 备份到 minio。

现在,我可以使用 PersistentVolume 备份应用程序,但是当我进行恢复时,卷中没有数据。我将在下面详细介绍,感谢社区为解决此问题提供的任何建议或帮助。

这是我遵循的步骤:

  1. 安装 Velero:
helm repo add vmware-tanzu https://vmware-tanzu.github.io/helm-charts
helm repo update
helm upgrade --install $RELEASE_NAME vmware-tanzu/velero \ 
  --namespace $NAMESPACE --create-namespace -f $VALUES_FILE
  1. 这是我使用的 helm values.yaml 文件的摘录,其中包含最重要的部分:
initContainers:
    - name: velero-plugin-for-aws
      image: velero/velero-plugin-for-aws:v1.6.1
      imagePullPolicy: IfNotPresent
      volumeMounts:
        - mountPath: /target
          name: plugins

  configuration:
    plugins:
      aws:
        image: velero/velero-plugin-for-aws:v1.2.0
      minio:
        image: velero/velero-plugin-for-minio:v1.2.0
  
    provider: aws
  
    backupStorageLocation:
      name: default 
      bucket: dev-velero-backup
      config:
        region: minio
        s3ForcePathStyle: "true"
        publicUrl: http://dev.api
        s3Url: "minio.tenant"
        insecureSkipTLSVerify: true
    
    volumeSnapshotLocation:
      region: minio
      name: default
      provider: aws
      config:
        region: minio
  
  # specify the credentials for minio.
  credentials:
    useSecret: true
    existingSecret: ""
    secretContents:
      cloud: |
        [default]
        aws_access_key_id = minio
        aws_secret_access_key = minio
      s3: ""
  
    features:
    namespace: velero
  backupsEnabled: true
  snapshotsEnabled: true
  1. 当我运行备份命令时,我可以看到在 minio 存储桶中创建的对象,因此 velero 和 minio 之间的通信没有问题。

  2. 这是我用来备份 nginx 示例应用程序的命令:

    velero backup create nginx-example --include-namespaces nginx-example --snapshot-volumes

备份完成,没有任何错误。

这是备份的日志:

time="2023-03-21T13:11:28Z" level=info msg="Executing RemapCRDVersionAction" backup=velero/nginx-example cmd=/velero logSource="pkg/backup/remap_crd_version_action.go:61" pluginName=velero
time="2023-03-21T13:11:28Z" level=info msg="Exiting RemapCRDVersionAction, the cluster does not support v1beta1 CRD" backup=velero/nginx-example cmd=/velero logSource="pkg/backup/remap_crd_version_action.go:89" pluginName=velero
time="2023-03-21T13:11:28Z" level=info msg="Backed up a total of 24 items" backup=velero/nginx-example logSource="pkg/backup/backup.go:413" progress=
  1. 下一步是模拟 DR 事件,通过删除 nginx-example 命名空间并验证应用程序的所有 k8s 资源都已销毁,包括 PV。

kubectl delete ns nginx-example
#Wait, and Check if pv is deleted.

  1. 当我尝试通过运行此命令从 velero 备份恢复 nginx-example 时:

velero restore create --from-backup nginx-example --include-namespaces nginx-example --restore-volumes

我可以在还原日志中看到以下消息:

velero restore logs nginx-example-20230321141504
time="2023-03-21T13:15:06Z" level=info msg="Waiting for all post-restore-exec hooks to complete" logSource="pkg/restore/restore.go:596" restore=velero/nginx-example-20230321141504
time="2023-03-21T13:15:06Z" level=info msg="Done waiting for all post-restore exec hooks to complete" logSource="pkg/restore/restore.go:604" restore=velero/nginx-example-20230321141504
time="2023-03-21T13:15:06Z" level=info msg="restore completed" logSource="pkg/controller/restore_controller.go:545" restore=velero/nginx-example-20230321141504
  1. 当我验证 nginx acess-logs 是否仍然包含以前访问的数据时,它是空的:

kubectl exec -it nginx-deploy-bf489bc5-8jrtz -- cat /var/log/nginx/access.log

nginx-example 应用程序在 PV 上安装了一个路径

/var/log/nginx

    spec:
      volumes:
        - name: nginx-logs
          persistentVolumeClaim:
           claimName: nginx-logs
      containers:
      - image: nginx:stable
        name: nginx
        ports:
        - containerPort: 80
        volumeMounts:
          - mountPath: "/var/log/nginx"
            name: nginx-logs
            readOnly: false

最终目标应该是使用包含访问日志数据的持久卷成功备份和恢复 nginx 示例应用程序。

如果这个问题能在您的帮助下得到解决,我将非常高兴,当然我会提供任何相关信息。

附加信息

  1. 卷快照位置
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
  annotations:
    helm.sh/hook: post-install,post-upgrade,post-rollback
    helm.sh/hook-delete-policy: before-hook-creation
  creationTimestamp: "2023-03-21T01:26:37Z"
  generation: 1
  labels:
    app.kubernetes.io/instance: velero-ontwikkel
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: velero
    helm.sh/chart: velero-3.1.4
  name: default
  namespace: velero
  resourceVersion: "83378185"
  uid: cea663dd-c1d9-4035-8c84-79a240f4351c
spec:
  config:
    region: minio
  provider: aws
  1. 已安装 velero 插件
NAME                                        KIND
velero.io/crd-remap-version                 BackupItemAction
velero.io/pod                               BackupItemAction
velero.io/pv                                BackupItemAction
velero.io/service-account                   BackupItemAction
velero.io/aws                               ObjectStore
velero.io/add-pv-from-pvc                   RestoreItemAction
velero.io/add-pvc-from-pod                  RestoreItemAction
velero.io/admission-webhook-configuration   RestoreItemAction
velero.io/apiservice                        RestoreItemAction
velero.io/change-pvc-node-selector          RestoreItemAction
velero.io/change-storage-class              RestoreItemAction
velero.io/cluster-role-bindings             RestoreItemAction
velero.io/crd-preserve-fields               RestoreItemAction
velero.io/init-restore-hook                 RestoreItemAction
velero.io/job                               RestoreItemAction
velero.io/pod                               RestoreItemAction
velero.io/pod-volume-restore                RestoreItemAction
velero.io/role-bindings                     RestoreItemAction
velero.io/service                           RestoreItemAction
velero.io/service-account                   RestoreItemAction
velero.io/aws                               VolumeSnapshotter

kubernetes backup minio disaster-recovery velero
1个回答
0
投票

您可能需要启用 NodeAgent 来进行卷备份,在 helm values.yaml 中添加 deployNodeAgent: true,以及何时备份使用选项 --default-volumes-to-fs-backup(像旧版本使用选项 --default-volumes -to-restic)。

velero backup create backup-test --include-namespaces nginx-example --default-volumes-to-fs-backup --snapshot-volumes --ttl 180h

完成备份后,您可以使用 --details 进行描述,您会发现类似这样的内容,您将知道卷备份成功。 velero 备份描述备份测试 --details

kopia Backups:
  Completed:
    nginx-example/nginx-deployment-5b47dbff44-cw9l4: nginx-logs
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.