pv绑定pvc
创建pv
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv003
labels:
app: vnc003
namespace: vnc-space
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
hostPath:
path: "/home/pv"
创建pvc
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc003
labels:
app: vnc003
namespace: vnc-space
spec:
# storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi
selector:
matchLabels:
app: vnc003
查看绑定情况
[root@lys-192 ~]# kubectl get pvc --show-labels
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE LABELS
pvc003 Bound pv004 5Gi RWX 10m app=vnc
pvc004 Bound pv003 5Gi RWX 5m42s app=vnc
[root@lys-192 ~]# kubectl get pv --show-labels
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE LABELS
pv003 5Gi RWX Retain Bound default/pvc004 4m19s app=vnc003
pv004 5Gi RWX Retain Bound default/pvc003 110s app=vnc003
创建pod使用pvc
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
role: web-frontend
namespace: vnc-space
spec:
containers:
- name: web
image: nginx
ports:
- name: web
containerPort: 80
volumeMounts:
- name: pv001
mountPath: "/usr/share/nginx/html"
volumes:
- name: pv001
persistentVolumeClaim: ## <--这字段
claimName: pvc003
————————————————
版权声明:本文为CSDN博主「liuyunshengsir」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/liuyunshengsir/article/details/88877427