pv 与pvc的绑定
2023-05-05 10:13:08 阅读次数:294
nginx
创建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
版权声明:本文内容来自第三方投稿或授权转载,原文地址:https://blog.51cto.com/liuyunshengsir/5998303,作者:liuyunshengsir,版权归原作者所有。本网站转在其作品的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如因作品内容、版权等问题需要同本网站联系,请发邮件至ctyunbbs@chinatelecom.cn沟通。
上一篇:Kubernetes的Sidecar模式
下一篇:git dev 分支merge到master