StorageClass

34次阅读
没有评论

root@k8s111:/home/k8s/volumes# kubectl apply -f nfs-provisioner-rbac.yaml 
clusterrole.rbac.authorization.k8s.io/nfs-client-provisioner-runner created
clusterrolebinding.rbac.authorization.k8s.io/run-nfs-client-provisioner created
role.rbac.authorization.k8s.io/leader-locking-nfs-client-provisioner created
rolebinding.rbac.authorization.k8s.io/leader-locking-nfs-client-provisioner created
root@k8s111:/home/k8s/volumes# kubectl apply -f nfs-provisioner-deployment.yaml 
serviceaccount/nfs-client-provisioner created
deployment.apps/nfs-client-provisioner created
root@k8s111:/home/k8s/volumes# kubectl apply -f nfs-storage-class.yaml 
storageclass.storage.k8s.io/managed-nfs-storage created
root@k8s111:/home/k8s/volumes# kubectl apply -f nfs-sc-demo-statefulset.yaml 
service/nginx-sc created
statefulset.apps/nginx-sc created
root@k8s111:/home/k8s/volumes# kubectl get sc
NAME                  PROVISIONER      RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
managed-nfs-storage   fuseim.pri/ifs   Retain          Immediate           false                  3m58s
root@k8s111:/home/k8s/volumes# kubectl get po -n kube-system | grep nfs
nfs-client-provisioner-5d67b7fb6c-q4kdb   0/1     ContainerCreating   0          5m49s

PVC处于pending状态的处理方案:

方案一:配置SelfLink

修改 apiserver 配置文件
vim /etc/kubernetes/manifests/kube-apiserver.yaml

spec:
  containers:
  - command:
    - kube-apiserver
    - --feature-gates=RemoveSelfLink=false # 新增该行
    ......

修改后重新应用该配置
kubectl apply -f /etc/kubernetes/manifests/kube-apiserver.yaml

方案二:不需要SelfLink的provisioner

将 provisioner 修改为如下镜像之一即可

gcr.io/k8s-staging-sig-storage/nfs-subdir-external-provisioner:v4.0.0

registry.cn-beijing.aliyuncs.com/pylixm/nfs-subdir-external-provisioner:v4.0.0

然后重新apply

kubectl apply -f nfs-provisioner-deployment.yaml

更新后可能还会pending一下,因为需要去拉取镜像。

kubectl get po -n kube-system|grep nfs

 ----     ------       ----                 ----               -------
  Normal   Scheduled    15m                  default-scheduler  Successfully assigned kube-system/nfs-client-provisioner-5d67b7fb6c-q4kdb to k8s113
  Warning  FailedMount  6m31s (x2 over 11m)  kubelet            Unable to attach or mount volumes: unmounted volumes=[nfs-client-root], unattached volumes=[kube-api-access-t4rfw nfs-client-root]: timed out waiting for the condition
  Warning  FailedMount  117s (x4 over 13m)   kubelet            Unable to attach or mount volumes: unmounted volumes=[nfs-client-root], unattached volumes=[nfs-client-root kube-api-access-t4rfw]: timed out waiting for the condition
  Warning  FailedMount  59s (x15 over 15m)   kubelet            MountVolume.SetUp failed for volume "nfs-client-root" : mount failed: exit status 32
Mounting command: mount
Mounting arguments: -t nfs 192.168.2.112:/data/nfs/rw /var/lib/kubelet/pods/50876352-aa02-4425-98fd-801f8f81440b/volumes/kubernetes.io~nfs/nfs-client-root
Output: mount: /var/lib/kubelet/pods/50876352-aa02-4425-98fd-801f8f81440b/volumes/kubernetes.io~nfs/nfs-client-root: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program.
       dmesg(1) may have more information after failed mount system call

正文完
 0
wujingquan
版权声明:本站原创文章,由 wujingquan 于2025-06-12发表,共计2716字。
转载说明:Unless otherwise specified, all articles are published by cc-4.0 protocol. Please indicate the source of reprint.
评论(没有评论)