Skip to content

Commit ba4579e

Browse files
author
Tim Bannister
committed
Add Windows examples for hostPath
Allow seeing an example of hostPath on Linux and on Windows
1 parent a6338f8 commit ba4579e

File tree

1 file changed

+52
-13
lines changed

1 file changed

+52
-13
lines changed

content/en/docs/concepts/storage/volumes.md

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -421,28 +421,64 @@ or modify the file permissions on the host to be able to read from
421421

422422
#### hostPath configuration example
423423

424-
This manifest mounts `/data` on the host as `/test-pd` inside the
425-
single container that runs within the `test-pd` Pod:
426-
427-
```yaml
424+
{{< tabs name="hostpath_examples" >}}
425+
{{< tab name="Linux node" codelang="yaml" >}}
426+
---
427+
# This manifest mounts /data/foo on the host as /foo inside the
428+
# single container that runs within the hostpath-example-linux Pod.
429+
#
430+
# The mount into the container is read-only.
428431
apiVersion: v1
429432
kind: Pod
430433
metadata:
431-
name: test-pd
434+
name: hostpath-example-linux
432435
spec:
436+
os: { name: linux }
437+
nodeSelector:
438+
kubernetes.io/os: linux
433439
containers:
434-
- image: registry.k8s.io/test-webserver
435-
name: test-container
440+
- name: example-container
441+
image: registry.k8s.io/test-webserver
436442
volumeMounts:
437-
- mountPath: /test-pd
438-
name: test-volume
443+
- mountPath: /foo
444+
name: example-volume
445+
readOnly: true
439446
volumes:
440-
- name: test-volume
447+
- name: example-volume
448+
# mount /data/foo, but only if that directory already exists
441449
hostPath:
442-
path: /data # directory location on host
450+
path: /data/foo # directory location on host
443451
type: Directory # this field is optional
444-
```
445-
452+
{{< /tab >}}
453+
{{< tab name="Windows node" codelang="yaml" >}}
454+
---
455+
# This manifest mounts C:\Data\foo on the host as C:\foo, inside the
456+
# single container that runs within the hostpath-example-windows Pod.
457+
#
458+
# The mount into the container is read-only.
459+
apiVersion: v1
460+
kind: Pod
461+
metadata:
462+
name: hostpath-example-windows
463+
spec:
464+
os: { name: windows }
465+
nodeSelector:
466+
kubernetes.io/os: windows
467+
containers:
468+
- name: example-container
469+
image: microsoft/windowsservercore:1709
470+
volumeMounts:
471+
- name: example-volume
472+
mountPath: "C:\\foo"
473+
readOnly: true
474+
volumes:
475+
# mount C:\Data\foo from the host, but only if that directory already exists
476+
- name: example-volume
477+
hostPath:
478+
path: "C:\\Data\\foo" # directory location on host
479+
type: Directory # this field is optional
480+
{{< /tab >}}
481+
{{< /tabs >}}
446482

447483
#### hostPath FileOrCreate configuration example {#hostpath-fileorcreate-example}
448484

@@ -465,6 +501,9 @@ kind: Pod
465501
metadata:
466502
name: test-webserver
467503
spec:
504+
os: { name: linux }
505+
nodeSelector:
506+
kubernetes.io/os: linux
468507
containers:
469508
- name: test-webserver
470509
image: registry.k8s.io/test-webserver:latest

0 commit comments

Comments
 (0)