You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Rancher Local-Path存储类PVC处于Pending状态:未指定节点配置错误

解决local-path存储类PVC Pending报错:"configuration error, no node was specified"

问题场景

使用local-path存储类创建PVC,且存储类的volumeBindingMode设为Immediate时,PVC始终处于Pending状态,核心报错为:

failed to provision volume with StorageClass "local-path": configuration error, no node was specified

PVC详情如下:

Name:          grafana-data
Namespace:     default
StorageClass:  local-path
Status:        Pending
Volume:
Labels:        io.kompose.service=grafana-data
Annotations:   volume.beta.kubernetes.io/storage-provisioner: rancher.io/local-path
               volume.kubernetes.io/storage-provisioner: rancher.io/local-path
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode:    Filesystem
Used By:       <none>
Events:
  Type     Reason                Age              From                                                                                                Message
  ----     ------                ----             ----                                                                                                -------
  Normal   Provisioning          8s               rancher.io/local-path_local-path-provisioner-7f68f98c9b-hqf5j_6e774f0a-bb44-4a4e-bfe8-a8781c321cf3  External provisioner is provisioning volume for claim "default/grafana-data"
  Warning  ProvisioningFailed    8s               rancher.io/local-path_local-path-provisioner-7f68f98c9b-hqf5j_6e774f0a-bb44-4a4e-bfe8-a8781c321cf3  failed to provision volume with StorageClass "local-path": configuration error, no node was specified
  Normal   ExternalProvisioning  8s (x2 over 8s)  persistentvolume-controller                                                                         waiting for a volume to be created, either by external provisioner "rancher.io/local-path" or manually created by system administrator

此前使用volumeBindingMode: WaitForConsumer可正常运行,因为该模式会等待Pod调度完成后再绑定存储,此时节点已确定;而Immediate模式会立即尝试创建PV,必须提前指定节点。

解决方案

方法1:给PVC添加节点指定注解

在PVC的annotations中添加节点选择注解,明确告知local-path provisioner要在哪个节点创建本地卷:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: grafana-data
  namespace: default
  labels:
    io.kompose.service: grafana-data
  annotations:
    volume.beta.kubernetes.io/storage-provisioner: rancher.io/local-path
    volume.kubernetes.io/storage-provisioner: rancher.io/local-path
    # 关键注解:指定目标节点名称
    volume.kubernetes.io/selected-node: <你的节点名称>
spec:
  storageClassName: local-path
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: <所需存储大小>

注:Kubernetes 1.14+推荐使用volume.kubernetes.io/selected-node,旧版本可替换为volume.beta.kubernetes.io/selected-node。

方法2:切换回WaitForConsumer模式(若业务允许)

如果不需要立即绑定PV,可修改local-path存储类的volumeBindingMode为WaitForConsumer,让provisioner等待Pod调度到节点后再创建本地卷,无需手动指定节点:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-path
provisioner: rancher.io/local-path
volumeBindingMode: WaitForConsumer
parameters:
  pathPattern: "/var/lib/local-path-provisioner/{{.PVC.Namespace}}/{{.PVC.Name}}"

内容的提问来源于stack exchange,提问作者kaffarell

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 01:50:29