删除所有的pv和pvc:
[root@server1 helm]# kubectl delete pvc --all
......
[root@server1 helm]# kubectl get pv
No resources found in default namespace.
[root@server1 helm]# kubectl get pvc
No resources found in default namespace.
删除之前部署的nfs-client:
[root@server1 ~]# cd volumes/pv/nfsclass/
[root@server1 nfsclass]# ls
class.yaml deployment.yaml pod.yaml pvc.yaml rbac.yaml
[root@server1 nfsclass]# kubectl delete -f .
storageclass.storage.k8s.io "managed-nfs-storage" deleted
deployment.apps "nfs-client-provisioner" deleted
serviceaccount "nfs-client-provisioner" deleted
clusterrole.rbac.authorization.k8s.io "nfs-client-provisioner-runner" deleted
clusterrolebinding.rbac.authorization.k8s.io "run-nfs-client-provisioner" deleted
role.rbac.authorization.k8s.io "leader-locking-nfs-client-provisioner" deleted
rolebinding.rbac.authorization.k8s.io "leader-locking-nfs-client-provisioner" deleted
Error from server (NotFound): error when deleting "pod.yaml": pods "test-pod" not found
Error from server (NotFound): error when deleting "pvc.yaml": persistentvolumeclaims "test-claim" not found
连接部署的原理:https://blog.csdn.net/qq_35887546/article/details/105861869#nfs_pv_194
查找chart:
[root@server1 nfsclass]# helm search repo nfs
NAME CHART VERSION APP VERSION DESCRIPTION
stable/nfs-client-provisioner 1.2.8 3.1.0 nfs-client is an automatic provisioner that use...
stable/nfs-server-provisioner 1.0.0 2.3.0 nfs-server-provisioner is an out-of-tree dynami...
由于nfs服务端我们已经部署好了,因此只部署nfs-client即可。
拉取及解压:
[root@server1 helm]# helm pull stable/nfs-client-provisioner
[root@server1 helm]# ls
mychart nfs-client-provisioner-1.2.8.tgz
[root@server1 helm]# tar xf nfs-client-provisioner-1.2.8.tgz
......
[root@server1 helm]# cd nfs-client-provisioner/
[root@server1 nfs-client-provisioner]# ls
Chart.yaml ci OWNERS README.md templates values.yaml
我们对版本文件不做更改,只更改变量文件:
[root@server1 nfs-client-provisioner]# vim values.yaml
[root@server1 nfs-client-provisioner]# kubectl create namespace nfs-client-provisioner
namespace/nfs-client-provisioner created
安装chart(-n选项指定namespace):
[root@server1 nfs-client-provisioner]# helm install nfs-client-provisioner . -n nfs-client-provisioner
NAME: nfs-client-provisioner
LAST DEPLOYED: Tue May 12 23:52:05 2020
NAMESPACE: nfs-client-provisioner
STATUS: deployed
REVISION: 1
TEST SUITE: None
查看:
[root@server1 nfs-client-provisioner]# helm list -n nfs-client-provisioner
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
nfs-client-provisioner nfs-client-provisioner 1 2020-05-12 23:52:05.651390456 +0800 CST deployed nfs-client-provisioner-1.2.8 3.1.0
查看pod状态:
[root@server1 nfs-client-provisioner]# kubectl -n nfs-client-provisioner get all
NAME READY STATUS RESTARTS AGE
pod/nfs-client-provisioner-65f7bdd89d-hthhc 1/1 Running 0 55s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nfs-client-provisioner 1/1 1 1 55s
NAME DESIRED CURRENT READY AGE
replicaset.apps/nfs-client-provisioner-65f7bdd89d 1 1 1 55s
部署成功。
查看创建的默认storageClass:
[root@server1 nfs-client-provisioner]# kubectl -n nfs-client-provisioner get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
nfs-client (default) cluster.local/nfs-client-provisioner Delete Immediate true 48m
创建pvc:
[root@server1 helm]# vim pvc.yaml
[root@server1 helm]# cat pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc1
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 300Mi
[root@server1 helm]# kubectl create -f pvc.yaml
persistentvolumeclaim/pvc1 created
查看pv和pvc已经发现部署成功:
[root@server1 helm]# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvc1 Bound pvc-00e836ef-43bb-4912-9b86-fe5131447eef 300Mi RWO nfs-client 6s
[root@server1 helm]# kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-00e836ef-43bb-4912-9b86-fe5131447eef 300Mi RWO Delete Bound default/pvc1 nfs-client 48s
实验后删除:
[root@server1 helm]# kubectl delete -f pvc.yaml
persistentvolumeclaim "pvc1" deleted
[root@server1 helm]# kubectl get pv
No resources found in default namespace.
[root@server1 helm]# kubectl get pvc
No resources found in default namespace.