结果展示
搭建NFS服务器
注意:安装nfs相关软件时需要在k8s的各个节点上都要安装
参考Centos7搭建NFS服务端
下载资源文件
# 如果实在下载不下来,就直接进入github进行拷贝
for file in class.yaml deployment.yaml rbac.yaml test-claim.yaml test-pod.yaml; \
do wget https://github.com/kubernetes-retired/external-storage/tree/master/nfs-client/deploy/$file; \
done
修改deployment.yaml
设置DefaultStorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
storageclass.kubernetes.io/is-default-class: "true" # 此属性为设置为default StorageClass
name: managed-nfs-storage
provisioner: fuseim.pri/ifs # or choose another name, must match deployment's env PROVISIONER_NAME'
parameters:
archiveOnDelete: "false"
部署
kubectl apply -f class.yaml
kubectl apply -f deployment.yaml
kubectl apply -f rbac.yaml
测试
kubectl apply -f test-claim.yaml
kubectl apply -f test-pod.yaml
如果创建的pvc一直处于pending状态,可按照如下方式解决
[问题描述](https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/issues/25)
# 解决:
# 修改apiserver的yaml文件
$ vim /etc/kubernetes/manifests/kube-apiserver.yaml
spec:
containers:
- command:
- kube-apiserver
- --feature-gates=RemoveSelfLink=false