Hello.
I'm experiencing a problem while trying to deploy a pod that has been configured to use a Persistent Volume. My installation is hosted on Hetzner Cloud and Kubernetes has been configured according to the instructions made available by the provider. The basic configuration seems ok since I can deploy e.g. Portainer from one of the provided manifests: it correctly mounts the PVC and runs. Since the default configuration doesn't create a persistent storage, every time I undeploy and redeploy Portainer all data are lost.
So I proceeded with the creation of a PersistentVolume
, but the final step doesn't work. I can't tell whether the problem is a generic Kubernetes one or it's with my integration with Hetzner - but I think it makes sense to check first the first hypothesis. So I'm asking here before going to the Hetzner forum.
Steps:
I created a Volume using the Hetzner Cloud user interface.
Then I deployed a PV:
apiVersion: v1
kind: Namespace
metadata:
name: portainer
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-portainer-test
namespace: portainer
labels:
env: test
spec:
storageClassName: portainer-test
accessModes:
- ReadWriteOnce
capacity:
storage: 10Gi
persistentVolumeReclaimPolicy: Retain
volumeMode: Filesystem
csi:
driver: csi.hetzner.cloud
fsType: ext4
volumeHandle: "pv_id"
pv_id
is the volume id that I can see with the Hetzner user interface.
I can see the PV with kubelet get pv -A
:
NAMESPACE NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
persistentvolume/pv-portainer-test 10Gi RWO Retain Available portainer-test 71s
Note that the namespace has not been defined... but I suppose this is not a serious issue. Maybe I'm wrong.
- I deployed Portainer from here and the following patch:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: portainer
namespace: portainer
spec:
storageClassName: portainer-test
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "10Gi"
Now with kubectl get pvc,pv -A
I see that the PVC has been bound to the PV:
NAMESPACE NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
portainer persistentvolumeclaim/portainer Bound pv-portainer-test 10Gi RWO portainer-test 16m
NAMESPACE NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
persistentvolume/pv-portainer-test 10Gi RWO Retain Bound portainer/portainer portainer-test 17m
- But the Portainer pod stays in the
ContainerCreating
status forever. Withkubectl describe
I see the reason:
Warning FailedAttachVolume 2s (x7 over 38s) attachdetach-controller AttachVolume.Attach failed for volume "pv-portainer-test" : rpc error: code = FailedPrecondition desc = failed to publish volume: volume is attached
So it seems it is complaining because the PV is already attached... but indeed it should have been attached precisely to that pod.