admin 管理员组文章数量: 1086019
I applied the following configuration with
- one RWO PV
- one RWO PVC
- two pods both using the above PVC.
apiVersion: v1
kind: PersistentVolume
metadata:
name: vol1
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 10Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: claim1
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi
---
apiVersion: v1
kind: Pod
metadata:
name: pod1
spec:
containers:
- name: myfrontend
image: nginx
volumeMounts:
- mountPath: "/var/www/html"
name: data
resources:
limits:
cpu: "1"
memory: "200Mi"
volumes:
- name: data
persistentVolumeClaim:
claimName: claim1
---
apiVersion: v1
kind: Pod
metadata:
name: pod2
spec:
containers:
- name: myfrontend
image: nginx
volumeMounts:
- mountPath: "/var/www/html"
name: data
resources:
limits:
cpu: "1"
memory: "200Mi"
volumes:
- name: data
persistentVolumeClaim:
claimName: claim1
The pods got scheduled onto two different nodes and, according to GitHub issues #103305 and #26567, I was expecting one of the two pods to fail (i.e. not reaching Running
state) because of the RWO
constraint.
However, both pods reached Running
state and I found that the pods were even able to write to the PVC
.
After having deleted all resources, I checked the two nodes and I found the data written by the pods. Actually, it seems that two different RWO PV were created and used.
Naturally, Kubernetes was showing just the PV and the PVC that were defined in the configuration.
How did Kubernetes managed this situation?
I've also tried not to define the PV
and let the cluster provision it. I made two experiments:
I defined the
PVC
andpod1
, applied the configuration, and then createdpod2
. The results didn't change: both pods were able to run and use thePVC
.I defined and applied
PVC
and both pods in one configuration. In this case, both pods (scheduled on different nodes) stuck atContainerCreating
while volume attachment was failing in loop.
Even though the second experiment outcome seems correct, I cannot find out why the first experiment went differently, since I just delayed the definition of pod2
.
本文标签: Kubernetes RWO PVC bound to two pods on different nodes seems to use two PVStack Overflow
版权声明:本文标题:Kubernetes: RWO PVC bound to two pods on different nodes seems to use two PV? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744030027a2521322.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论