gpt4 book ai didi

kubernetes - 使用新的 PersistentVolume 重新创建由 StatefulSet 管理的 Pod

转载 作者:行者123 更新时间:2023-12-02 11:39:01 26 4
gpt4 key购买 nike

偶尔,我需要对 StatefulSet 中的所有 Pod 执行滚动替换,以便所有 PV 也从头开始重新创建。这样做的原因是摆脱所有使用旧版本加密 key 的底层硬盘驱动器。此操作不应与常规滚动升级混淆,我仍然希望卷在 Pod 终止后继续存在。到目前为止,我认为最好的例程如下:

  • 删除 PV。
  • 删除PVC。
  • 删除 Pod。
  • 等到所有删除完成。
  • 手动重新创建步骤 2 中删除的 PVC。
  • 等待新 Pod 完成从 StatefulSet 中的其他 Pod 流式传输数据。
  • 对下一个 Pod 从步骤 1. 重复。

  • 我对第 5 步不满意。我希望 StatefulSet 为我重新创建了 PVC,但不幸的是它没有。我必须自己做,否则 Pod 创建失败并出现以下错误:
    Warning  FailedScheduling   3s (x15 over 15m)  default-scheduler   persistentvolumeclaim "foo-bar-0" not found

    有没有更好的方法来做到这一点?

    最佳答案

    我只是最近不得不这样做。以下对我有用:

    # Delete the PVC
    $ kubectl delete pvc <pvc_name>

    # Delete the underlying statefulset WITHOUT deleting the pods
    $ kubectl delete statefulset <statefulset_name> --cascade=false

    # Delete the pod with the PVC you don't want
    $ kubectl delete pod <pod_name>

    # Apply the statefulset manifest to re-create the StatefulSet,
    # which will also recreate the deleted pod with a new PVC
    $ kubectl apply -f <statefulset_yaml>

    关于kubernetes - 使用新的 PersistentVolume 重新创建由 StatefulSet 管理的 Pod,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60867164/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com