項目地址:https://github.com/kubernetes-incubator/external-storage.git
使用示例架構(gòu):
說明:
nfs默認不支持動態(tài)存儲湿颅,使用了第三方的NFS插件
項目插件地址:https://github.com/kubernetes-incubator/external-storage/tree/master/nfs-client/deploy
部署nfs StorageClass:
- clone項目
git clone https://github.com/kubernetes-incubator/external-storage.git
cd external-storage/nfs-client/deploy
- 部署rbac:
kubectl apply -f rbac.yaml
- 部署nfs clinet插件
注意偎血,deployment.yaml里面的image默認是國外,需要改為自己鏡像倉庫,
下面的需要改為自己的nfs信息
env:
- name: PROVISIONER_NAME
value: fuseim.pri/ifs
- name: NFS_SERVER
value: 10.10.10.60 #NFS地址
- name: NFS_PATH #nfs路徑
value: /ifs/kubernetes
volumes:
- name: nfs-client-root
nfs:
server: 10.10.10.60 #NFS地址
path: /ifs/kubernetes #NFS路徑
kubectl apply -f deployment.yaml
kubectl apply -f class.yaml
- class.yaml文件詳解
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: managed-nfs-storage
provisioner: fuseim.pri/ifs # deployment的env里面的PROVISIONER_NAME的值
parameters:
archiveOnDelete: "false"
使用:
- 創(chuàng)建pvc
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-claim
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage" #這里指定的是class.yaml的name
spec:
accessModes:
- ReadWriteMany #運行所有主機讀寫掛載
resources:
requests:
storage: 1Mi #存儲大小
- pod使用pvc
kind: Pod
apiVersion: v1
metadata:
name: test-pod
spec:
containers:
- name: test-pod
image: gcr.io/google_containers/busybox:1.24
command:
- "/bin/sh"
args:
- "-c"
- "touch /mnt/SUCCESS && exit 0 || exit 1"
volumeMounts:
- name: nfs-pvc
mountPath: "/mnt"
restartPolicy: "Never"
volumes:
- name: nfs-pvc
persistentVolumeClaim:
claimName: test-claim #pvc名字
我的blog
https://www.iyunw.cn