Kubernetes NFS-Client Provisioner创建Storageclass

Kubernetes NFS-Client Provisioner创建Storageclass。

第一步,安装nfs-server。

yum -y install nfs-utils rpcbind
rpcinfo -p localhost

mkdir -p /nfs4k8s
chmod a+w /nfs4k8s

echo "/nfs4k8s *(rw,async,no_root_squash)" >> /etc/exports
exportfs -r

systemctl start rpcbind
systemctl start nfs-server

systemctl enable rpcbind
systemctl enable nfs-server

showmount -e localhost

第二步,安装nfs-client。(xxx.xxx.xxx.xxx修改为各自nfs-server的IP)

helm install stable/nfs-client-provisioner --name aliyun-storageclass --set nfs.server=xxx.xxx.xxx.xxx --set nfs.path=/nfs4k8s

helm fetch stable/nfs-client-provisioner
helm template nfs-client-provisioner-1.2.6.tgz
helm install nfs-client-provisioner-1.2.6.tgz --name aliyun-storageclass --namespace public-service --set nfs.server=xxx.xxx.xxx.xxx --set nfs.path=/nfs4k8s --set imagePullPolicy=IfNotPresent

第三步,确认。

创建test.yaml。

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: testclaim
spec:
  storageClassName: "nfs-client"
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Mi

发布test.yaml。

kubectl apply -f test.yaml

确认pv,pvc。

kubectl get pv,pvc
NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                                        STORAGECLASS                      REASON   AGE
persistentvolume/pvc-c4191314-5dd9-4cac-a4c0-dea717ad29c2   10Mi       RWX            Delete           Bound    default/testclaim                                            nfs-client                                 3s

NAME                              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/testclaim   Bound    pvc-c4191314-5dd9-4cac-a4c0-dea717ad29c2   10Mi       RWX            nfs-client     3s

结尾!

你可能感兴趣的:(Kubernetes)