This document describes the current state of Volumes in kubernetes. Familiarity with pods 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.
A Pod specifies which Volumes its containers need in its ContainerManifest 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 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 a VolumeMounts property.
The storage media (Disk, SSD, or memory) of a volume is determined by the media of the filesystem holding the kubelet root dir (typically /var/lib/kubelet
).
There is no limit on how much space an EmptyDir or PersistentDir volume can consume, and no isolation between containers or between pods.
In the future, we expect that a Volume will be able to request a certain amount of space using a resource specification, and to select the type of media to use, for clusters that have several media types.
Kubernetes currently supports three types of Volumes, but more may be added in the future.
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. When a Pod is unbound, the data in the EmptyDir is deleted forever.
Some uses for an EmptyDir are:
Currently, the user cannot control what kind of media is used for an EmptyDir. If the Kubelet is configured to use a disk drive, then all EmptyDirectories 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.
A Volume with a HostDir property allows access to files on the current node.
Some uses for a HostDir are:
Watch out when using this type of volume, because:
Important: You must create a PD using gcloud
or the GCE API before you can use it
A Volume with a GCEPersistentDisk property allows access to files on a Google Compute Engine (GCE) Persistent Disk.
There are some restrictions when using a GCEPersistentDisk:
Before you can use a GCE PD with a pod, you need to create it.
gcloud compute disks create --size=500GB --zone=us-central1-a my-data-disk
apiVersion: v1beta1
desiredState:
manifest:
containers:
- image: kubernetes/pause
name: testpd
volumeMounts:
- mountPath: "/testpd"
name: "testpd"
id: testpd
version: v1beta1
volumes:
- name: testpd
source:
persistentDisk:
# This GCE PD must already exist.
pdName: test
fsType: ext4
id: testpd
kind: Pod
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。