https://rancher.com/ logo
Title
a

able-library-94454

03/09/2023, 4:08 AM
I'm reading the longhorn documentation and looking over the CSI Persistent Volume example. I see the spec.csi.volumeHandle parameter as pointing to an already created longhorn volume and trying to understand the usage of the csi section. What I've been trying to find is a reference of the options that are possible under the spec.csi section - I figured there must be a reference somewhere but can't find one, just examples but not a formal spec. I've even tried reading the Go code and haven't found where that section is parsed. Can someone steer me in the direction of a definitive reference for this section?
c

creamy-pencil-82913

03/09/2023, 4:32 AM
Persistent Volumes and PV Claims are core Kubernetes, have you looked at the docs there?
Generally you just create a PVC with the correct storage class and let the system handle provisioning and binding a PV for you though.
đź‘Ť 1
a

able-library-94454

03/09/2023, 4:56 AM
@creamy-pencil-82913 I do have a general understanding of pv and pvc's, but what I'm trying to understand now is the only example using CSI specifies an already created volume in Longhorn and I haven't found anything that says it uses CSI to let the system provision the volume. But CSI sounds like a general driver interface. I see the docs you're pointing to at https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/volume/, but there's no mention of the volumeHandle parameter there so that's why Google didn't return it in my search.
@creamy-pencil-82913 When I ran the CSI Persistent Volume section yaml from https://staging--longhornio.netlify.app/docs/0.8.1/references/examples/#csi-persistent-volume it did not create a new volume that I could see in the Longhorn dashboard and the volume-pv-test failed to deploy. It wasn't until I used the longhorn dashboard to manually create a volume named "existing-longhorn-volume" that the given example worked. So that's why I'm now trying to figure out if there is a variation of that example that would go ahead and create the volume for me, or whenever I use the csi section in the spec do I have to have already created the longhorn volume, which doesn't sound right to me. Can you help steer me straight?
c

creamy-pencil-82913

03/09/2023, 5:56 AM
yes, because that example there binds a PV to an existing longhorn volume named
existing-longhorn-volume
. If you just want a new volume created for you you shouldn’t set that.
If you just want a new volume, leave the PV bit out and just create a new PVC without a volumeName. Let Kubernetes create the PV for you.
also I’m not sure how you ended up on the ancient 0.8.1 staging docs
f

famous-shampoo-18483

03/09/2023, 4:14 PM
Since normal Kubernetes workloads cannot directly use an existing volume, and they would recognize PVC/PV only. To utilize the existing volumes, we need to create PVC/PV for it then the workload can pick it up. This is why we provide the example.
c

creamy-pencil-82913

03/09/2023, 5:05 PM
Yeah I think that’s the source of the confusion though. You don’t have to use an existing volume.
a

able-library-94454

03/09/2023, 6:01 PM
@creamy-pencil-82913 @famous-shampoo-18483 Thanks both. I think one reason for the confusion is that in the examples section you have the block volume example which does create a new longhorn volume followed right by the CSI Persistent Volume section with the only clue that this example requires a manually configured volume that it is named "existing-longhorn-volume" which is actually pretty subtle for documentation to indicate that other steps are required to run that example. I'd suggest a quick paragraph or comment above that example to make that more explicit. But my other bit of confusion is over CSI - does the block volume example above it really NOT use the CSI driver? I see that the CSI Persistent Volume section has the csi section, but does this really mean that completely different drivers are being used? I finally did find this discussion where someone else had the same confusion I did, so maybe the documention could more directly address this to help others? https://github.com/longhorn/longhorn/discussions/2190
c

creamy-pencil-82913

03/09/2023, 6:18 PM
the block volume example doesn’t use a Volume at all, just a PVC with the StorageClass and volumeMode set correctly. You don’t need to manually create a volume or a PV at all, no
The examples are quite comprehensive, but you need to understand what they’re actually demonstrating.
a

able-library-94454

03/09/2023, 6:20 PM
@creamy-pencil-82913 That's why I'm suggesting that maybe a comment would make it easier to understand. I really did try to read the docs to understand what was going on, but that was a bit subtle.