如何删除 Azure FileShare 快照以及 Azure Kubernetes 服务中的持久卷?

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

我正在使用 Azure Kubernetes 服务 (AKS),其中我使用 Azure FileShares 配置了持久卷 (PV)。其中一些 FileShare 已启用备份功能。当我删除持久卷声明 (PVC) 时,我希望关联的持久卷 (PV) 和 FileShare 也会被删除。

对于没有备份的 FileShare,删除过程按预期进行。但是,对于启用备份的文件共享,我遇到了问题。当尝试删除与 PVC 关联的 PV 时,我收到以下错误:

storage.FileSharesClient#Delete: Failure sending request: StatusCode=409 --
  Original Error: autorest/azure: Service returned an error. Status=<nil>
  Code="DeleteShareWhenSnapshotLeased" Message="Unable to delete share because
  one or more share snapshots have active leases. Release the share snapshot
  leases or delete the share with the include-leased parameter for
  x-ms-delete-snapshots."

尽管成功删除了 PVC,PV 仍处于“已释放”状态,并且由于快照上的活动租约,关联的 FileShare 并未被删除。

我已验证 FileShare 启用了软删除属性,并且没有阻止编辑资源组的锁定。

我已检查快照或内部文件中是否有任何“租赁”属性,但没有找到任何可以释放以允许删除 FileShare 的属性。它仅在停止备份过程并删除备份数据(在 Azure 门户中)后才起作用。 PV 和 FileShare 已被删除,无需任何其他操作。

在 AKS 中删除 PV 时,是否有办法自动(并可能强制)删除所有快照以及 FileShare,即使快照上有活动租约?

编辑: kubernetes版本是1.27.7; StorageClass使用api版本:storage.k8s.io/v1; PersistentVolumeClaim 和 PersistentVolume 使用 apiVersion: v1.

azure kubernetes persistent-volumes azure-files azure-backup-vault
1个回答
0
投票

在 Azure Kubernetes 服务中,当您使用 Azure FileShare 作为持久卷的后备存储并启用备份时,如果这些文件共享由于有效租用而具有快照,则在删除这些文件共享时可能会遇到问题。根据设计,删除文件共享时,Azure 不会自动删除文件共享的快照,以防止意外数据丢失。当启用备份功能时,此行为尤其相关,因为这些备份依赖于快照。

当您删除持久卷声明 (PVC) 时,Kubernetes 会向 Azure 发送请求以删除相应的文件共享。但是,如果存在任何具有有效租约的快照,Azure 将阻止此请求以防止潜在的数据丢失,从而导致 PV 保留在“已发布”状态而没有被完全删除。

要解决此问题,您可以在尝试删除 PV 之前使用 Azure CLI 或 Azure 门户手动删除快照。

 az storage share delete \
    --name arkoshare \
    --account-name arkostore \
    --snapshot <snapshot-id>

enter image description here enter image description here

参考资料:

© www.soinside.com 2019 - 2024. All rights reserved.