Skip to content

Commit

Permalink
add doc for hostpath type
Browse files Browse the repository at this point in the history
  • Loading branch information
dixudx committed Sep 25, 2017
1 parent 99fbc2b commit fe3b711
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions docs/concepts/storage/volumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,40 @@ spec:
### 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
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`
* allowing a pod to specify whether a given hostPath should exist prior to the
pod running, whether it should be created, and what it should exist as

In addition to the required `path` property, user can optionally specify a `type` for a `hostPath` volume.

The supported values for field `type` are:


| Value | Behavior |
|:------|:---------|
| | Empty string (default) are for backward compatibility, which means that no checks will be performed before mounting the hostPath volume. |
| `DirectoryOrCreate` | If nothing exists at the given path, an empty directory will be created there as needed with file mode 0755, having the same group and ownership with Kubelet. |
| `Directory` | A directory must exist at the given path |
| `FileOrCreate` | If nothing exists at the given path, an empty file will be created there as needed with file mode 0644, having the same group and ownership with Kubelet. |
| `File` | A file must exist at the given path |
| `Socket` | A UNIX socket must exist at the given path |
| `CharDevice` | A character device must exist at the given path |
| `BlockDevice` | A block device must exist at the given path |

Watch out when using this type of volume, because:

* 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`
* the directories created on the underlying hosts are only writable by root. You
* the files or directories created on the underlying hosts are only writable by root. You
either need to run your process as root in a
[privileged container](/docs/user-guide/security-context) or modify the file
permissions on the host to be able to write to a `hostPath` volume
Expand All @@ -180,6 +198,8 @@ spec:
hostPath:
# directory location on host
path: /data
# this field is optional
type: Directory
```

### gcePersistentDisk
Expand Down

0 comments on commit fe3b711

Please sign in to comment.