Resizing PVC for a Kubernetes Statefulset

Ellie Huxtable

为 Kubernetes Statefulset 调整 PVC 容量

如果你曾尝试为数据库部署(或类似场景)调整 Kubernetes StatefulSet 的 PVC 容量,很可能见过下面这个错误:

Internal server error

StatefulSet.apps "es-cluster" is invalid: spec: Forbidden: updates to statefulset > spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden.

  1. 手动编辑所有 PVC:kubectl edit pvc -n <namespace> <name>
  2. 删除 StatefulSet,但保留 Pod 继续运行:kubectl delete -n <namesapce> statefulset --cascade=orphan <name>
  3. 使用 helm upgradekubectl apply 或你平时部署用的其他方式重新创建 StatefulSet
  4. 重启 StatefulSet 以重新部署所有 Pod:kubectl rollout restart statefulset -n namespace <name>

原文由 Ellie Huxtable 发布

本文章由 stealth/ox-alpha 进行翻译