StatefulSet部署时PVC创建失败,需支持副本因子1的卷创建
问题描述
部署关联PVC的StatefulSet时,卷创建失败。
事件报错
9s Warning ProvisioningFailed persistentvolumeclaim/kafka-vol-kafka-0 Failed to provision volume with StorageClass "hello-sc": rpc error: code = Internal desc = Failed to create volume: This IO profile requires a minimum replication factor of 2 nodes
当前PVC状态
kubectl get pvc -n hello NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE hello-vol-hello-0 Pending hell-sc 44m
存储类配置
Name: hello-sc IsDefaultClass: Yes Annotations: kubectl.kubernetes.io/last-applied-configuration={"allowVolumeExpansion":true,"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"},"name":"hello-sc"},"parameters":{"cow_ondemand":"true","disable_io_profile_protection":"true","fs":"ext4","io_profile":"db_remote","priority_io":"high","repl":"1"},"provisioner":"kubernetes.io/portworx-volume","reclaimPolicy":"Delete","volumeBindingMode":"Immediate"} ,storageclass.kubernetes.io/is-default-class=true Provisioner: kubernetes.io/portworx-volume Parameters: cow_ondemand=true,disable_io_profile_protection=true,fs=ext4,io_profile=db_remote,priority_io=high,repl=1 AllowVolumeExpansion: True MountOptions: <none> ReclaimPolicy: Delete VolumeBindingMode: Immediate Events: <none>
需求
部署带PVC的StatefulSet时,要求设置副本因子(repl)为1也能成功创建卷。
解决方案
问题根因
错误信息明确指出,当前使用的io_profile=db_remote要求最小复制因子为2,但存储类中设置了repl=1。虽然配置了disable_io_profile_protection=true,但该参数可能未生效或Portworx版本不支持绕过此限制。
解决步骤
方案1:更换兼容单副本的IO Profile
将io_profile改为支持单副本的类型(如db或default),修改存储类参数:
parameters: cow_ondemand: "true" fs: "ext4" io_profile: "db" # 替换为兼容单副本的profile priority_io: "high" repl: "1"
方案2:确保disable_io_profile_protection参数生效
- 确认Portworx版本支持该参数,若版本过低则升级Portworx。
- 检查参数值是否为字符串格式
"true"(而非布尔值),重新编辑存储类:kubectl edit storageclass hello-sc
后续操作
修改存储类后,删除处于Pending状态的PVC,让StatefulSet重新触发卷创建:
kubectl delete pvc hello-vol-hello-0 -n hello
等待片刻后检查PVC状态:
kubectl get pvc -n hello
内容的提问来源于stack exchange,提问作者Janardhan
相关产品推荐
相关产品推荐

