1

我们正在尝试在 Rancher 中配置本地存储,并且存储配置器配置成功。但是当我使用 local-storage sc 创建 pvc 时,它会进入挂起状态并出现以下错误。

   Normal   ExternalProvisioning  4m31s (x62 over 19m)  persistentvolume-controller                                                                         waiting for a volume to be created, either by external provisioner "rancher.io/local-path" or manually created by system administrator
  Normal   Provisioning          3m47s (x7 over 19m)   rancher.io/local-path_local-path-provisioner-5f8f96cb66-8s9dj_f1bdad61-eb48-4a7a-918c-6827e75d6a27  External provisioner is provisioning volume for claim "local-path-storage/test-pod-pvc-local"
  Warning  ProvisioningFailed    3m47s (x7 over 19m)   rancher.io/local-path_local-path-provisioner-5f8f96cb66-8s9dj_f1bdad61-eb48-4a7a-918c-6827e75d6a27  failed to provision volume with StorageClass "local-path": configuration error, no node was specified
[root@n01-deployer local]#

sc配置

[root@n01-deployer local]# kubectl edit  sc local-path
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"local-path"},"provisioner":"rancher.io/local-path","reclaimPolicy":"Delete","volumeBindingMode":"Immediate"}
  creationTimestamp: "2022-02-07T16:12:58Z"
  name: local-path
  resourceVersion: "1501275"
  uid: e8060018-e4a8-47f9-8dd4-c63f28eef3f2
provisioner: rancher.io/local-path
reclaimPolicy: Delete
volumeBindingMode: Immediate

PVC配置

[root@n01-deployer local]# cat pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  namespace: local-path-storage
  name: test-pod-pvc-local-1

spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: local-path
  resources:
    requests:
      storage: 5Gi
  volumeMode: Filesystem
 

我已经在所有工作节点中安装了本地卷,但我的 pvc 仍未创建。有人可以帮我解决这个问题吗?

4

1 回答 1

1

问题的关键是更新 PSP。

我想补充一些关于 PSP 的内容:

根据此文档此博客

从 Kubernetes 版本 1.21开始,PodSecurityPolicy (beta) 已被弃用。Kubernetes 项目旨在在1.25 版本中关闭该功能 。

但是我在 Rancher 的案例中没有找到任何信息(文档是最新的)。

Rancher 附带了两个默认的 Pod 安全策略 (PSP):restrictedunrestricted策略。


也可以看看:

于 2022-02-11T16:47:47.710 回答