Controlling PV and PVC binding

I’m fairly new to Rancher but I have some experience from configuring Kubernetes at work.

I’m a little confused on volumes in Rancher. For example, I go to deploy the gitlab-ce chart and it creates four PVCs: data (RWO 10Gi), etc (RWO 1Gi), postgresql (RWO 10Gi), and redis (RWO 10Gi). Aside from the accessMode and the storage, there’s nothing to distinguish them, so how do I ensure that a PVC binds to a particular PV?

At work I would do this by adding labels to the PVs and matchLabels to the PVCs, but these aren’t even visible in the Rancher UI.

Thanks.

I use kubectl to achieve this
here is a pv definition
apiVersion: v1
kind: PersistentVolume
metadata:
name: name-of-pv
namespace: XXXX
spec:
storageClassName: “longhorn”
capacity:
storage: 2Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
csi:
driver: io.rancher.longhorn
fsType: ext4
volumeAttributes:
numberOfReplicas: ‘3’
staleReplicaTimeout: ‘30’
volumeHandle: xxxx
you can use any CSI that works for you
and here is the corresponding PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata: name-of the-claim
namespace: xxxx
selfLink: /api/v1/namespaces/xxxxx/persistentvolumeclaims/name-of the-claim
spec:
accessModes:

  • ReadWriteOnce
    dataSource: null
    resources:
    requests:
    storage: 2Gi
    storageClassName: “longhorn”
    volumeMode: Filesystem
    volumeName: volume name from the pv definition

I hope this helps