Kubernetes 集群挂载高可用 NFS 网络文件存储

2021-05-31  本文已影响0人  hwholiday

安装NFS高可用集群

安装 nfs-client-provisioner

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3

chmod 700 get_helm.sh

./get_helm.sh

helm repo add azure http://mirror.azure.cn/kubernetes/charts/

helm install nfs-storage azure/nfs-client-provisioner --set nfs.server="172.12.17.200" --set nfs.path=/fs/nsf-data --set storageClass.name=nfs-hw

创建PVC

kubectl apply -f nfs-pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-pvc-test
spec:
  storageClassName: "nfs-hw"
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi

测试

kubectl apply -f nfs-test.yaml

apiVersion: batch/v1
kind: Job
metadata:
  name: nfsjob
spec:
  template:
    spec:
      containers:
      - name: bbox1
        image: busybox
        args:
        - /bin/sh
        - -c
        - echo "1231231231" > /nfs-data/hello
        volumeMounts:
        - mountPath: "/nfs-data"
          name: nfsdata
      restartPolicy: Never
      volumes:
      - name: nfsdata
        persistentVolumeClaim:
          claimName: nfs-pvc-test

end

K8S 集群是 v1.20+,在 nfs provisioner 创建 pvc 时,nfs provisioner 会报错

上一篇下一篇

猜你喜欢

热点阅读