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
- 接下来去看看 NFS 服务器上是否有对应文件文件
K8S 集群是 v1.20+,在 nfs provisioner 创建 pvc 时,nfs provisioner 会报错
- selfLink在1.16版本以后已经弃用,在1.20版本停用。
- 要解决这个问题只需要在kube-api添加--feature-gates=RemoveSelfLink=false 即可,
参考:kubernetes-sigs/nfs-subdir-external-provisioner#25