Kubernetes PersistentVolume and PersistentVolumeClaim could be causing issues for my pod which crashes while copying logs
Creating the PVC dynamically provisioned a PV instead of using the one you created manually with the hostpath
. On the PVC simply set .spec.storageClassName
to and an empty string (""
)
From the documentation:
A PVC with its storageClassName set equal to
""
is always interpreted to be requesting a PV with no class, so it can only be bound to PVs with no class (no annotation or one set equal to ""). A PVC with no storageClassName is not quite the same ...
So create something like this (I've also added labels and selectors to make sure that the intended PV is paired up the PVC; you might not need that constraint):
apiVersion: v1kind: PersistentVolumemetadata: name: mypv-shared labels: name: mypv-sharedspec: accessModes: - ReadWriteMany capacity: storage: 5Gi hostPath: path: /data/mypv-shared/---apiVersion: v1kind: PersistentVolumeClaimmetadata: name: mypv-shared-claimspec: storageClassName: "" selector: matchLabels: name: mypv-shared accessModes: - ReadWriteMany resources: requests: storage: 5Gi