Change:
# Volumes <del> This document describes the current state of Volumes in kubernetes.  Familiarity with [pods](./pods.md) is suggested. A Volume is a directory, possibly with some data in it, which is accessible to a Container. Kubernetes Volumes are similar to but not the same as [Docker Volumes](https://docs.docker.com/userguide/dockervolumes/). A Pod specifies which Volumes its containers need in its [spec.volumes](http://kubernetes.io/third_party/swagger-ui/#!/v1/createPod) property. A process in a Container sees a filesystem view composed from two sources: a single Docker image and zero or more Volumes.  A [Docker image](https://docs.docker.com/userguide/dockerimages/) is at the root of the file hierarchy.  Any Volumes are mounted at points on the Docker image;  Volumes do not mount on other Volumes and do not have hard links to other Volumes.  Each container in the Pod independently specifies where on its image to mount each Volume.  This is specified in each container's VolumeMounts property. </del> <ins> On-disk files in a container are ephemeral, which presents some problems for non-trivial applications when running in containers.  First, when a container crashes kubelet will restart it, but the files will be lost lost - the container starts with a clean slate.  second, when running containers together in a `Pod` it is often necessary to share files between those containers.  The Kubernetes `Volume` abstraction solves both of these problems. Familiarity with [pods](./pods.md) is suggested. ## Background Docker also has a concept of [volumes](https://docs.docker.com/userguide/dockervolumes/), though it is somewhat looser and less managed.  In Docker, a volume is simply a directory on disk or in another container.  Lifetimes are not managed and until very recently there were only local-disk-backed volumes.  Docker now provides volume drivers, but the functionality is very limited for now (e.g. as of Docker 1.7 only one volume driver is allowed per container and there is no way to pass parameters to volumes). A Kubernetes volume, on the other hand, has an explicit lifetime - the same as the pod that encloses it.  Consequently, a volume outlives any containers that run within the Pod, and data is preserved across Container restarts. Of course, when a Pod ceases to exist, the volume will cease to exist, too.  Perhaps more importantly than this, Kubernetes supports many type of volumes, and a Pod can use any number of them simultaneously. At its core, a volume is just a directory, possibly with some data in it, which is accessible to the containers in a pod.  How that directory comes to be, the medium that backs it, and the contents of it are determined by the particular volume type used. To use a volume, a pod specifies what volumes to provide for the pod (the [spec.volumes](http://kubernetes.io/third_party/swagger-ui/#!/v1/createPod) field) and where to mount those into containers(the [spec.containers.volumeMounts](http://kubernetes.io/third_party/swagger-ui/#!/v1/createPod) field). A process in a container sees a filesystem view composed from their Docker image and volumes.  The [Docker image](https://docs.docker.com/userguide/dockerimages/) is at the root of the filesystem hierarchy, and any volumes are mounted at the specified paths within the image.  Volumes can not mount onto other volumes or have hard links to other volumes.  Each container in the Pod must independently specify where to mount each volume. </ins> ## Types of Volumes <del> Kubernetes currently supports multiple types of Volumes: emptyDir, gcePersistentDisk, awsElasticBlockStore, gitRepo, secret, nfs, iscsi, glusterfs, persistentVolumeClaim, rbd. The community welcomes additional contributions. Selected volume types are described below. ### EmptyDir An EmptyDir volume is created when a Pod is bound to a Node.  It is initially empty, when the first Container command starts.  Containers in the same pod can all read and write the same files in the EmptyDir volume.  When a Pod is unbound, the data in the EmptyDir is deleted forever. Some uses for an EmptyDir are: </del> <ins> Kubernetes supports several types of Volumes: * emptyDir * hostPath * gcePersistentDisk * awsElasticBlockStore * nfs * iscsi * glusterfs * rbd * gitRepo * secret * persistentVolumeClaim We welcome additional contributions. ### emptyDir An `emptyDir` volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node.  As the name says, it is initially empty.  Containers in the pod can all read and write the same files in the `emptyDir` volume, though that volume can be mounted at the same or different paths in each container.  When a Pod is removed from a node for any reason, the data in the `emptyDir` is deleted forever.  NOTE: a container crashing does *NOT* remove a pod from a node, so the data in an `emptyDir` volume is safe across container crashes. Some uses for an `emptyDir` are: * scratch space, such as for a disk-based mergesortcw * checkpointing a long computation for recovery from crashes * holding files that a content-manager container fetches while a webserver container serves the data By default, `emptyDir` volumes are stored on whatever medium is backing the machine - that might be disk or SSD or network storage, depending on your environment.  However, you can set the `emptyDir.medium` field to `"Memory"` to tell Kubernetes to mount a tmpfs (RAM-backed filesystem) for you instead. While tmpfs is very fast, be aware that unlike disks, tmpfs is cleared on machine reboot and any files you write will count against your container's memory limit. ### hostPath A `hostPath` volume mounts a file or directory from the host node's filesystem into your pod.  This is not something that most Pods will need, but it offers a powerful escape hatch for some applications. For example, some uses for a `hostPath` are: * running a container that needs access to Docker internals; use a `hostPath` of `/var/lib/docker` * running cAdvisor in a container; use a `hostPath` of `/dev/cgroups` </ins> <del> * scratch space, such as for a disk-based mergesort or checkpointing a long computation, * a directory that a content-manager container fills with data while a webserver container serves the data. Currently, the user cannot control what kind of media is used for an EmptyDir (see also the section _Resources_, below).  If the Kubelet is configured to use a disk drive, then all EmptyDir volumes will be created on that disk drive.  In the future, it is expected that Pods can control whether the EmptyDir is on a disk drive, SSD, or tmpfs. </del> <ins> Watch out when using this type of volume, because: </ins> <del> ### HostPath A Volume with a HostPath property allows access to files on the current node. </del> <ins> * pods with identical configuration (such as created from a podTemplate) may behave differently on different nodes due to different files on the nodes * when Kubernetes adds resource-aware scheduling, as is planned, it will not be able to account for resources used by a `hostPath` </ins> <del> Some uses for a HostPath are: </del> <ins> ### gcePersistentDisk </ins> <del> * running a container that needs access to Docker internals; use a HostPath of /var/lib/docker. * running cAdvisor in a container; use a HostPath of /dev/cgroups. </del> <ins> A `gcePersistentDisk` volume mounts a Google Compute Engine (GCE) [Persistent Disk](http://cloud.google.com/compute/docs/disks) into your pod.  Unlike `emptyDir`, which is erased when a Pod is removed, the contents of a PD are preserved and the volume is merely unmounted.  This means that a PD can be pre-populated with data, and that data can be "handed off" between pods. </ins> <del> Watch out when using this type of volume, because: </del> <ins> __Important: You must create a PD using ```gcloud``` or the GCE API or UI before you can use it__ </ins> <del> * pods with identical configuration (such as created from a podTemplate) may behave differently on different nodes due to different files on different nodes. * When Kubernetes adds resource-aware scheduling, as is planned, it will not be able to account for resources used by a HostPath. </del> <ins> There are some restrictions when using a `gcePersistentDisk`: </ins> <del> ### GCEPersistentDisk __Important: You must create a PD using ```gcloud``` or the GCE API before you can use it__ </del> <ins> * the nodes on which pods are running must be GCE VMs * those VMs need to be in the same GCE project and zone as the PD </ins> <del> A Volume with a GCEPersistentDisk property allows access to files on a Google Compute Engine (GCE) [Persistent Disk](http://cloud.google.com/compute/docs/disks). </del> <ins> A feature of PD is that they can be mounted as read-only by multiple consumers simultaneously.  This means that you can pre-populate a PD with your dataset and then serve it in parallel from as many pods as you need.  Unfortunately, PDs can only be mounted by a single consumer in read-write mode - no simultaneous readers allowed. </ins> <del> There are some restrictions when using a GCEPersistentDisk: * the nodes (what the kubelet runs on) need to be GCE VMs * those VMs need to be in the same GCE project and zone as the PD * avoid creating multiple pods that use the same Volume if any mount it read/write. * if a pod P already mounts a volume read/write, and a second pod Q attempts to use the volume, regardless of if it tries to use it read-only or read/write, Q will fail. * if a pod P already mounts a volume read-only, and a second pod Q attempts to use the volume read/write, Q will fail. * replication controllers with replicas > 1 can only be created for pods that use read-only mounts. </del> <ins> Using a PD on a pod controlled by a ReplicationController will will fail unless the PD is read-only or the replica count is 0 or 1. </ins> #### Creating a PD Before you can use a GCE PD with a pod, you need to create it. ```sh gcloud compute disks create --size=500GB --zone=us-central1-a my-data-disk ``` <del> #### GCE PD Example configuration: </del> <ins> #### Example pod </ins> ```yaml apiVersion: v1 kind: Pod metadata: <del> name: testpd </del> <ins> name: test-pd </ins> spec: containers: <del> - image: kubernetes/pause name: testcontainer </del> <ins> - image: gcr.io/google_containers/test-webserver name: test-container </ins> volumeMounts: <del> - mountPath: /testpd name: testvolume </del> <ins> - mountPath: /test-pd name: test-volume </ins> volumes: <del> - name: testvolume # This GCE PD must already exist. </del> <ins> - name: test-volume # This GCE PD must already exist. </ins> gcePersistentDisk: <del> pdName: test </del> <ins> pdName: my-data-disk </ins> fsType: ext4 ``` <del> ### AWSElasticBlockStore __Important: You must create an EBS volume using ```aws ec2 create-volume``` or the AWS API before you can use it__ </del> <ins> ### awsElasticBlockStore </ins> <del> A Volume with an awsElasticBlockStore property allows access to files on a AWS [EBS volume](http://aws.amazon.com/ebs/) </del> <ins> An `awsElasticBlockStore` volume mounts an Amazon Web Services (AWS) [EBS Volume](http://aws.amazon.com/ebs/) into your pod.  Unlike `emptyDir`, which is erased when a Pod is removed, the contents of an EBS volume are preserved and the volume is merely unmounted.  This means that an EBS volume can be pre-populated with data, and that data can be "handed off" between pods. __Important: You must create an EBS volume using ```aws ec2 create-volume``` or the AWS API before you can use it__ </ins> There are some restrictions when using an awsElasticBlockStore volume: <del> * the nodes (what the kubelet runs on) need to be AWS EC2 instances </del> <ins> * the nodes on which pods are running must be AWS EC2 instances </ins> * those instances need to be in the same region and availability-zone as the EBS volume * EBS only supports a single EC2 instance mounting a volume #### Creating an EBS volume Before you can use a EBS volume with a pod, you need to create it. ```sh

Discussion:
only talks about these volumes: EmptyDir HostPath GCEPersistentDisk NFS However, we many more volume types. Documentation should be updated to reflect this.
cc
Is anyone working on this? If not, I would like to do it.
go for it :) Improving PV docs is on my TODO list, too.
Sure, thank you. I will start now, hope to send a PR ASAP.