74 lines
1.1 KiB
Markdown
74 lines
1.1 KiB
Markdown
**PVC的创建**
|
|
|
|
````
|
|
kind: PersistentVolume
|
|
apiVersion: v1
|
|
metadata:
|
|
name: task-pv-volume
|
|
labels:
|
|
type: local
|
|
spec:
|
|
storageClassName: manual
|
|
capacity:
|
|
storage: 10Gi
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
hostPath:
|
|
path: "/mnt/data"
|
|
---
|
|
kind: PersistentVolumeClaim
|
|
apiVersion: v1
|
|
metadata:
|
|
name: task-pv-claim
|
|
spec:
|
|
storageClassName: manual
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
resources:
|
|
requests:
|
|
storage: 3Gi
|
|
|
|
````
|
|
|
|
**NFS类型的PVC**
|
|
|
|
````
|
|
kind: PersistentVolumeClaim
|
|
apiVersion: v1
|
|
metadata:
|
|
name: pvc-nfs
|
|
spec:
|
|
storageClassName: nfs-slow
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
resources:
|
|
requests:
|
|
storage: 3Gi
|
|
|
|
````
|
|
|
|
**PVC的使用**
|
|
|
|
````
|
|
kind: Pod
|
|
apiVersion: v1
|
|
metadata:
|
|
name: task-pv-pod
|
|
spec:
|
|
volumes:
|
|
- name: task-pv-storage
|
|
persistentVolumeClaim:
|
|
claimName: task-pv-claim
|
|
containers:
|
|
- name: task-pv-container
|
|
image: nginx
|
|
ports:
|
|
- containerPort: 80
|
|
name: "http-server"
|
|
volumeMounts:
|
|
- mountPath: "/usr/share/nginx/html"
|
|
name: task-pv-storage
|
|
|
|
````
|
|
|