基于nfs创建pv、pvc,关联pod
1、基于nfs创建pvapiVersion: v1kind: PersistentVolumemetadata:name: newpvspec:capacity:storage: 5GiaccessModes:- ReadWriteOncepersistentVolumeReclaimPolicy: Recycle storageClassName: slownfs:path: /zg-k8s-t
1、基于nfs创建pv
apiVersion: v1
kind: PersistentVolume
metadata:
name: newpv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
storageClassName: slow
nfs:
path: /zg-k8s-test-storage/k8s
server: n0.XXta.nas.xxyun.com ##这里写nfs的服务器路径。
2、创建pvc
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: myclaim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: slow
3、创建pod,关联PVC
kind: Pod
apiVersion: v1
metadata:
name: mypod
spec:
containers:
- name: myfrontend
image: harbor.XX.cn/library/nginx:zuol #镜像路径
volumeMounts:
- mountPath: "/var/www/html"
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: myclaim
注意:红色的注意必须一致,紫色的也必须一致。
更多推荐
所有评论(0)