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 17, 2017
1 parent 286f2cb commit e42d860
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions docs/concepts/storage/volumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,37 @@ 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

Supported HostPath Types are:

| Value | Behavior |
|:------|:---------|
| *unset* | For backwards compatible, leave it empty if unset. **Default value**. |
| `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 +195,8 @@ spec:
hostPath:
# directory location on host
path: /data
# this field is optional
type: Directory
```

### gcePersistentDisk
Expand Down

0 comments on commit e42d860

Please sign in to comment.