删除pod并将其重新部署后,持久卷不会保留现有数据。
一旦吊舱被移除,映射的永久卷状态将更改为已发布。稍后,当重新部署同一吊舱时,由于它不在 Available (可用)状态,因此我们无法使用相同的现有PV。
根据https://kubernetes.io/docs/concepts/storage/persistent-volumes/#retain中的建议,
我尝试删除已发布 PV,并创建了状态为 Available 且其绑定到重新创建的pod,但缺少旧数据。
当吊舱被删除并重新创建后,我们如何才能与旧数据主张相同的PV?
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-storage
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: kubernetes.io/no-provisioner
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer
-------------------------------
apiVersion: v1
kind: PersistentVolume
metadata:
name: app-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
local:
path: /data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: role
operator: In
values:
- data