Kubernetes Deep Dive

Sign Up Free or Log In to participate!

Is it possible to mount an existing AW-EBS volume as a Storage Class in Kubernetes?

It seems that Storage classes uses the provisioner to create a new volume. How about reusing an existing one? I don’t see any way to specify a Volume-ID for the AWS provisioner.

3 Answers

Hi Christian.

I’m 99% sure you cannot do this with a Storage Class. The kubernetes.io/aws-ebs provisioner does not have a field that lets you specify an exiting volume – obviously the whole idea of them is creating volume dynamically. I’m also not aware of the PVC object having a way to do this. It basically calls on a Storage Class (provisioner) and can set things like access mode and capacity, but not a specific volume.

HTH. Nigel

Christian vW-Jensen

Hi Nigel. Thanks for this great course. I’m enjoying it very much. So how would you go about using an existing EBS volume in a Kubernetes cluster? In my case, I’m migrating from a Docker Swarm cluster to k8s. But I have several volumes of data, I want to carry over.

Christian vW-Jensen

Yes, I can see that. I wonder if this can be turned into a PersistantVolume, so you can make a pvc on it?

nigelpoulton

Yeah, I reckon it’s doable on AWS. I’ve posted another ANSWER as comments to this thread lose all formatting. HTH.

Hi Christian. Howe about trying this.

Configure your Storage Classes etc as normal. But for this requirement that needs a specific volume, manually create a PersistentVolume (PV) and then a claim on it (PVC). The PV definition below should give you a starting place and you can put in your own values as required…

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv1
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 20Gi
  persistentVolumeReclaimPolicy: Retain
  awsElasticBlockStore:
    volumeID: <your-id-in-here> # This is the `vol-...` bit shown in the AWS console

I’ve not tested it, but something you might be able to test yourself and report back…

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?