Docker -v (volume mount) equivalent in kubernetes

11/2/2017

I am looking for a kubernetes equivalent of docker -v for mounting the volumes in gcloud.

I am trying to run my container using google-container-engine which uses kubectl to manage clusters. In the kubectl run command I could not fund any provision for mounting the volumes.

 kubectl run foo --image=gcr.io/project_id/myimage --port 8080

I checkout their official docs but could not find any clue whatsoever.

-- Prakash Palnati
docker
google-kubernetes-engine
kubernetes

1 Answer

11/2/2017

As at the moment, It's not possible to mount a persistent Volume in a container by using imperative ways or using generators command (run, expose).Therefore, You could use declarative way to get it done.

Kubernetes provides 2 abstractions for storage in a cluster which are persistent volume claim (PVC) and persistent volume (PV). Moreover, you can use storage class to provide Persistent volume (PV) in a dynamic way.

persistent-volumes.

storage-classes

When you write a manifest file for deployment you need to use a volume claim field to access PVC as well as you will write a PVC to claim PV.

-- Suresh Vishnoi
Source: StackOverflow