Mounting an existing volume to LKE
I have a previous docker setup where I keep persistent data in some mounted network volumes using the linode docker volume driver, and I was wanting to move to K8s but I don't want to lose this data, so I was wondering if there was a way to re-mount these volumes using the Linode CSI?
I kind of already asked in the github issues section but I'm guessing something like this would work?:
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-persistentvolume
annotations:
pv.kubernetes.io/provisioned-by: linodebs.csi.linode.com
spec:
storageClassName: linode-block-storage-retain
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
claimRef:
namespace: default
name: my-persistentvolumeclaim
csi:
driver: linodebs.csi.linode.com
volumeHandle: <linode_volume_label>
readOnly: false
fsType: ext4
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-persistentvolumeclaim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: linode-block-storage-retain
volumeName: my-persistentvolume
but it seems like this isn't working. does the CSI driver have support for re-mounting existing volumes? Or do I have to manually move all this data into the new volumes created through the CSI driver?
6 Replies
@JonathanKurumi the Linode CSI driver doesn't currently support remounting existing disk. At this time, you'll need to move your data over onto the new volumes. I understand how inconvenient this is, and I've made sure our developers are aware of this feature request. I'm also going to create a ticket in our internal tracker to record this feature request.
Existing volumes can be mounted, since that is an inherent property of the CSI driver. For instance, if you backup a cluster with CSI devices, and restore that cluster, your CSI devices (and existing block storage devices) would have to be remounted.
The trick is in discovering the correct incantation of volume ids and labels to embed in the PV yaml.
https://github.com/linode/linode-blockstorage-csi-driver/issues/24 is an open issue looking for improvements in the CSI documentation for the Static Provisioning workflow.
The PV and PVC yaml below work for me. Replace {ID}-{LABEL}
with your Volume ID and Label (which you can get from linode-cli
). Update the storage size too, I used the default minimum size of 10Gi
. Volumes must reside in the same region as the cluster and the volume must not already be attached to a Linode instance.
apiVersion: v1
kind: PersistentVolume
metadata:
name: existing-volume
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 10Gi
csi:
driver: linodebs.csi.linode.com
fsType: ext4
volumeHandle: {ID}-{Label}
persistentVolumeReclaimPolicy: Retain
storageClassName: linode-block-storage-retain
volumeMode: Filesystem
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-claim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: linode-block-storage-retain
volumeMode: Filesystem
volumeName: existing-volume
---
You can test this by creating the following busybox pod:
kind: Pod
apiVersion: v1
metadata:
name: busybox-pod
spec:
containers:
- name: busybox-container
image: busybox
volumeMounts:
- mountPath: "/data"
name: data-volume
command: [ "sleep", "1000000" ]
volumes:
- name: data-volume
persistentVolumeClaim:
claimName: my-claim
Attach to the pod to explore your data:
kubectl exec -it busybox-pod -- ls -la /data # /bin/sh is available
I've tried with the same yaml file, updating {ID}-{Label} with my volume information from linode-cli.
The volume is not attached to any linode.
I've the following error in the pod events when launching it:
Warning FailedAttachVolume 6s (x5 over 14s) attachdetach-controller AttachVolume.Attach failed for volume "existing-volume" : rpc error: code = Internal desc = [403] Unauthorized
What's wrong?
The presence of an 403 Unauthorized error makes me believe that you might not be passing along a valid Kubernetes secret through the Linode Block Storage CSI driver.
This Kubernetes secret is used to store a Linode Personal Access Token (or PAT for short). The CSI driver must have a valid PAT so that it has the authorization to modify your Linode account's services.
You may generate and review your PATs review on this page in Cloud Manager:
I would ensure that your token has read/write access to Kubernetes and Block Storage at the very least. You may need more access permissions depending on what you're trying to achieve.
Once you generate this token, you should be able to supply it as a Kubernetes secret with these instructions in our CSI driver's README.
I hope my suggestion here resolves this issue for you. If you're still having trouble, we'll be happy to assist you further.
@jo_pis3 have you solve that problem??
Warning FailedAttachVolume 6s (x5 over 14s) attachdetach-controller AttachVolume.Attach failed for volume "existing-volume" : rpc error: code = Internal desc = [403] Unauthorized
I follow any instruction here but it's not working. by the way I make volume manually from admin volume manager, is it wrong? any body help me? thanks.