kubenetes系列-部署csi-driver-nfs

1、部署helm

#这里要注意因为下周的是二进制直接可用,需要根据系统去下载
wget https://get.helm.sh/helm-v3.14.2-linux-amd64.tar.gz
tar xf helm-v3.14.2-linux-amd64.tar.gz && cd linux-arm64 && mv helm /usr/bin/

2、使用helm部署

helm pull csi-driver-nfs/csi-driver-nfs --untar
helm repo add csi-driver-nfs https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/charts
#需要改 为dnsPolicy:ClusterFirs
[root@master csi-driver-nfs]# cat values.yaml |grep dnsPolicy
  dnsPolicy: ClusterFirst  # available values: Default, ClusterFirstWithHostNet, ClusterFirst
  dnsPolicy: ClusterFirs  # available values: Default, ClusterFirstWithHostNet, ClusterFirst

#镜像因为是国外的镜像,需要更改为国内或者自行想办法下载这里就不过多介绍
cd csi-driver-nfs
[root@master csi-driver-nfs]# cat values.yaml |sed -n 's#registry.k8s.io/sig-storage#registry.aliyuncs.com/google_containers#p'
        repository: registry.aliyuncs.com/google_containers/nfsplugin
        repository: registry.aliyuncs.com/google_containers/csi-provisioner
        repository: registry.aliyuncs.com/google_containers/csi-snapshotter
        repository: registry.aliyuncs.com/google_containers/livenessprobe
        repository: registry.aliyuncs.com/google_containers/csi-node-driver-registrar
        repository: registry.aliyuncs.com/google_containers/snapshot-controller

#直接helm部署
[root@master pvc]# helm install csi-derver-nfs ./csi-driver-nfs -n kube-system
NAME: csi-derver-nfs
LAST DEPLOYED: Wed Mar  6 14:51:58 2024
NAMESPACE: kube-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The CSI NFS Driver is getting deployed to your cluster.

To check CSI NFS Driver pods status, please run:

  kubectl --namespace=kube-system get pods --selector="app.kubernetes.io/instance=csi-derver-nfs" --watch


#根据提示查看知道running
kubectl --namespace=kube-system get pods --selector="app.kubernetes.io/instance=csi-derver-nfs" --watch

3、部署StorageClass

#这是yaml
[root@master pvc]# cat sc-nfs.yml allowVolumeExpansion: true apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: nfs-csi provisioner: nfs.csi.k8s.io parameters: server: 172.16.149.203 share: /nfsdata reclaimPolicy: Delete volumeBindingMode: Immediate mountOptions: - hard - nfsvers=3 - nolock
#这里执行部署
[root@master pvc]# kubectl apply -f sc-nfs.yml

4、部署pvc测试是否成功

#pvc的yaml
[root@master pvc]# cat pvc.yml 
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pv-volume
spec:
  storageClassName: nfs-csi
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1G


#直接执行文件
kubectl apply -f pvc.yml

#查看pvc是否绑定pv
[root@master pvc]# kubectl get pvc
NAME        STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
pv-volume   Bound    pvc-6519c8ff-f828-4142-bfd0-c531a83e02f9   1G         RWO            nfs-csi        19m
[root@master pvc]# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM               STORAGECLASS   REASON   AGE
app-data                                   2Gi        RWO            Retain           Available                                               4h59m
pvc-6519c8ff-f828-4142-bfd0-c531a83e02f9   1G         RWO            Delete           Bound       default/pv-volume   nfs-csi                 19m
#发现已自动绑定上,

至此部署完成参考文献:https://github.com/kubernetes-csi/csi-driver-nfs/tree/master/charts

posted @ 2024-03-06 15:16  Throb_JL  阅读(219)  评论(0编辑  收藏  举报