@@ -421,28 +421,64 @@ or modify the file permissions on the host to be able to read from
421
421
422
422
# ### hostPath configuration example
423
423
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.
428
431
apiVersion : v1
429
432
kind : Pod
430
433
metadata :
431
- name: test-pd
434
+ name : hostpath-example-linux
432
435
spec :
436
+ os : { name: linux }
437
+ nodeSelector :
438
+ kubernetes.io/os : linux
433
439
containers :
434
- - image: registry.k8s.io/test-webserver
435
- name: test-container
440
+ - name : example-container
441
+ image : registry.k8s.io/ test-webserver
436
442
volumeMounts :
437
- - mountPath: /test-pd
438
- name: test-volume
443
+ - mountPath : /foo
444
+ name : example-volume
445
+ readOnly : true
439
446
volumes :
440
- - name: test-volume
447
+ - name : example-volume
448
+ # mount /data/foo, but only if that directory already exists
441
449
hostPath :
442
- path: /data # directory location on host
450
+ path : /data/foo # directory location on host
443
451
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 >}}
446
482
447
483
# ### hostPath FileOrCreate configuration example {#hostpath-fileorcreate-example}
448
484
@@ -465,6 +501,9 @@ kind: Pod
465
501
metadata:
466
502
name: test-webserver
467
503
spec:
504
+ os: { name: linux }
505
+ nodeSelector:
506
+ kubernetes.io/os: linux
468
507
containers:
469
508
- name: test-webserver
470
509
image: registry.k8s.io/test-webserver:latest
0 commit comments