k8s基于NFS创建Storageclass

结果展示

image.png

搭建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

image.png

设置DefaultStorageClass

image.png
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

你可能感兴趣的:(k8s基于NFS创建Storageclass)