Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I specify persistent volumes when defining a Kubernetes replication controller in Google Cloud?

I see in the docs how do do this for pods, but I want to use a replication controller to manage my pods, ensuring that there is always one up at all times.

  1. How can I define a replication controller where the pod being run has a persistent volume?

  2. How is this related to Kubernetes persistentVolumes and persistentVolumeClaims?

like image 666
Eric Avatar asked Jul 17 '15 17:07

Eric


2 Answers

Using a persistent volume in a Replication Controller works great for shared storage. You include a persistentVolumeClaim in the RC's pod template. Each pod will use the same claim, which means it's shared storage. This also works for read-only access in gcloud if your Replica count > 1.

If you wanted distinct volumes per pod, you currently have to create many RCs with Replicas=1 and with distinct persistentVolumeClaims.

We're working out a design for scaling storage through an RC where each pod gets its own volume instead of sharing the same claim.

like image 169
Mark Turansky Avatar answered Oct 17 '22 23:10

Mark Turansky


Please note that persistent volumes are linked to a node, they are not shared throughout the cluster. That is probably the reason you didn't find information about the replication controller with persistent volumes. Because replication controllers are not limited to running one node.

If you are using the Google Cloud, look into GCEPersistentVolume https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs/user-guide/persistent-volumes

Another option, though not production ready is: https://clusterhq.com/2015/04/24/data-migration-kubernetes-flocker/

like image 2
PJong Avatar answered Oct 17 '22 22:10

PJong