Я запускаю один мастер/узел Kubernetes на виртуальной машине, используя hostPath
в качестве постоянного тома для развернутой базы данных Postgres.
Мой PersistentVolume
имеет следующие конфиги:
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
volume.beta.kubernetes.io/storage-class: postgres
labels:
type: local
name: postgres-storage
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
hostPath:
path: /data/postgres
Кроме того, у меня есть PersistentVolumeClaim
, в настоящее время привязанный к этому тому, запрашивающий всю емкость (spec.resources.requests.storage: 1Gi
).
Недавно база данных Postgres превысила размер spec.capacity.storage
, однако без каких-либо проблем:
$ du -hs /data/postgres # Powers of 1024
1.2G /data/postgres
$ du -hs /data/postgres --si # Powers of 1000
1.3G /data/postgres
Мой вопрос:
Согласно @wongma7 на странице Kubernetes GitHub:
this is working as intended, kube can't/won't enforce the capacity of PVs, the capacity field on PVs is just a label. It's up to the "administrator" i.e. the creator of the PV to label it accurately so that when users create PVCs that needs >= X Gi, they get what they want.
Вы можете найти оригинальное обсуждение здесь.
Кроме того, это описано в официальной документации Объем/Ресурсы:
There is no limit on how much space an
emptyDir
orhostPath
volume can consume, and no isolation between Containers or between Pods.In the future, we expect that emptyDir and hostPath volumes will be able to request a certain amount of space using a resource specification, and to select the type of media to use, for clusters that have several media types.
О, я вижу это... После дальнейшего изучения я даже нашел
capacity
соображения дляhostPath
томов в официальные документы. Я позволил себе отредактировать ваш ответ, чтобы добавить эту информацию.