nfs-client-provisioner使用
作者:互联网
nfs服务器搭建:
1. 挂载硬盘(一般使用单独的硬盘)
mount /dev/sdb /nfsdata
2. 安装包
yum install nfs-utils rpcbind -y
3. 修改/etc/exports文件
# cat /etc/exports
/nfsdata *(rw,sync,no_root_squash,no_subtree_check)
4. 启动nfs-server和rpcbind
systemctl start nfs-server rpcbind
systemctl enable nfs-server rpcbind
5. 查看nfs是否就绪
# showmount -e
nfs-client-provisioner配置:
git clone https://github.com/kubernetes-incubator/external-storage.git
cd external-storage/nfs-client/deploy
1. 创建serviceAccount
kubectl apply -f objects/serviceaccount.yaml
2. 创建StorageClass(sc)
kubectl apply -f class.yaml
3. 创建nfs-client-provisioner deployment
修改deployment.yaml中NFS服务器所在IP地址和NFS存储目录,其他均不用改
apiVersion: apps/v1
kind: Deployment
metadata:
name: nfs-client-provisioner
labels:
app: nfs-client-provisioner
# replace with namespace where provisioner is deployed
namespace: default
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: nfs-client-provisioner
template:
metadata:
labels:
app: nfs-client-provisioner
spec:
serviceAccountName: nfs-client-provisioner
containers:
- name: nfs-client-provisioner
image: quay.io/external_storage/nfs-client-provisioner:latest
volumeMounts:
- name: nfs-client-root
mountPath: /persistentvolumes
env:
- name: PROVISIONER_NAME
value: fuseim.pri/ifs
- name: NFS_SERVER
value: 172.20.192.117
- name: NFS_PATH
value: /nfsdata/pv3
volumes:
- name: nfs-client-root
nfs:
server: 172.20.192.117
path: /nfsdata/pv3
4. 设置权限
kubectl apply -f rbac.yaml
5. 测试pvc(pod与pvc一一对应)
kubectl apply -f test-claim.yaml
kuctl get pvc
6. 测试pod
kubectl apply -f test-pod.yaml
7. 查看nfs服务器,已有文件
ls -lh /nfsdata/pv3/default-test-claim-pvc-344dcbf9-2122-46a6-85ed-8de42c7f23ef/SUCCESS
标签:kubectl,name,yaml,client,nfs,provisioner 来源: https://blog.csdn.net/weixin_42758299/article/details/117693099