初始化
yum install -y nfs-utils
systemctl enable --now nfs-server
systemctl status nfs-server
添加了 NFS Subdir External Provisioner 的 Helm 仓库
helm repo add nfs-subdir-external-provisioner https://charts.helm.sh/incubator
helm repo list
helm repo update
安装
helm install nfs-client nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
--set nfs.server=10.0.0.100 \
--set nfs.path=/home/nfs \
--set storageClass.name=nfs-storage
安装后检查
kubectl get pods -n kube-system
测试
chmod 777 /home/nfs
```
[root@4c8-k8s-all ~]$ cat nfs-ceshi.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nfs-deployment
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: nfs
template:
metadata:
labels:
app: nfs
spec:
containers:
- name: nfs-container
image: alpine
command: ["/bin/sh", "-c", "while true; do sleep 30; done;"]
volumeMounts:
- mountPath: /mnt/nfs
name: nfs-storage
volumes:
- name: nfs-storage
nfs:
server: 10.0.0.100
path: /home/nfs
```
kubectl exec -it nfs-deployment-6c4f87ffcd-tsbts -- /bin/sh
touch /mnt/nfs/test-file
ls /mnt/nfs
ls能出来东西就说明是成功的
评论区