@@ -497,7 +497,7 @@ to mount in a Pod. You can specify single or multiple target world wide names (W
497
497
using the parameter `targetWWNs` in your Volume configuration. If multiple WWNs are specified,
498
498
targetWWNs expect that those WWNs are from multi-path connections.
499
499
-->
500
- # ## fc ( 光纤通道) {#fc}
500
+ # ## fc( 光纤通道) {#fc}
501
501
502
502
` fc` 卷类型允许将现有的光纤通道块存储卷挂载到 Pod 中。
503
503
可以使用卷配置中的参数 `targetWWNs` 来指定单个或多个目标 WWN(World Wide Names)。
@@ -580,7 +580,7 @@ clones the repo using Git, then mount the
580
580
` gitRepo` 卷类型已经被弃用。
581
581
582
582
如果需要制备已挂载 Git 仓库的 Pod,你可以将
583
- [EmptyDir](#emptydir) 卷挂载到 [Init 容器](/zh-cn/docs/concepts/workloads/pods/init-containers/) 中,
583
+ [EmptyDir](#emptydir) 卷挂载到 [Init 容器](/zh-cn/docs/concepts/workloads/pods/init-containers/)中,
584
584
使用 Git 命令完成仓库的克隆操作,然后将 [EmptyDir](#emptydir) 卷挂载到 Pod 的容器中。
585
585
586
586
---
@@ -591,12 +591,12 @@ You can restrict the use of `gitRepo` volumes in your cluster using
591
591
[ValidatingAdmissionPolicy](/docs/reference/access-authn-authz/validating-admission-policy/).
592
592
You can use the following Common Expression Language (CEL) expression as
593
593
part of a policy to reject use of `gitRepo` volumes :
594
- ` has(object.spec.volumes) || !object.spec.volumes.exists(v, has(v.gitRepo))` .
594
+ ` ! has(object.spec.volumes) || !object.spec.volumes.exists(v, has(v.gitRepo))` .
595
595
-->
596
596
你可以使用 [ValidatingAdmissionPolicy](/zh-cn/docs/reference/access-authn-authz/validating-admission-policy/)
597
597
这类[策略](/zh-cn/docs/concepts/policy/)来限制在你的集群中使用 `gitRepo` 卷。
598
598
你可以使用以下通用表达语言(CEL)表达式作为策略的一部分,以拒绝使用 `gitRepo` 卷:
599
- ` has(object.spec.volumes) || !object.spec.volumes.exists(v, has(v.gitRepo))` 。
599
+ ` ! has(object.spec.volumes) || !object.spec.volumes.exists(v, has(v.gitRepo))` 。
600
600
{{< /warning >}}
601
601
602
602
<!--
@@ -788,19 +788,38 @@ root 身份运行进程,或者修改主机上的文件权限,以便能够从
788
788
-->
789
789
# ### hostPath 配置示例
790
790
791
+ {{< tabs name="hostpath_examples" >}}
792
+
791
793
<!--
792
794
Linux node
795
+ ---
793
796
# This manifest mounts /data/foo on the host as /foo inside the
794
797
# single container that runs within the hostpath-example-linux Pod.
795
798
#
796
799
# The mount into the container is read-only.
797
-
798
- # mount /data/foo, but only if that directory already exists
799
-
800
- # directory location on host
801
- # this field is optional
800
+ apiVersion : v1
801
+ kind : Pod
802
+ metadata :
803
+ name : hostpath-example-linux
804
+ spec :
805
+ os : { name: linux }
806
+ nodeSelector :
807
+ kubernetes.io/os : linux
808
+ containers :
809
+ - name : example-container
810
+ image : registry.k8s.io/test-webserver
811
+ volumeMounts :
812
+ - mountPath : /foo
813
+ name : example-volume
814
+ readOnly : true
815
+ volumes :
816
+ - name : example-volume
817
+ # mount /data/foo, but only if that directory already exists
818
+ hostPath :
819
+ path : /data/foo # directory location on host
820
+ type : Directory # this field is optional
802
821
-->
803
- {{< tabs name="hostpath_examples" >}}
822
+
804
823
{{< tab name="Linux 节点" codelang="yaml" >}}
805
824
---
806
825
# 此清单将主机上的 /data/foo 挂载为 hostpath-example-linux Pod 中运行的单个容器内的 /foo
@@ -831,15 +850,32 @@ spec:
831
850
832
851
<!--
833
852
Windows node
853
+ ---
834
854
# This manifest mounts C:\Data\foo on the host as C:\foo, inside the
835
855
# single container that runs within the hostpath-example-windows Pod.
836
856
#
837
857
# The mount into the container is read-only.
838
-
839
- # mount C:\Data\foo from the host, but only if that directory already exists
840
-
841
- # directory location on host
842
- # this field is optional
858
+ apiVersion : v1
859
+ kind : Pod
860
+ metadata :
861
+ name : hostpath-example-windows
862
+ spec :
863
+ os : { name: windows }
864
+ nodeSelector :
865
+ kubernetes.io/os : windows
866
+ containers :
867
+ - name : example-container
868
+ image : microsoft/windowsservercore:1709
869
+ volumeMounts :
870
+ - name : example-volume
871
+ mountPath : " C:\\ foo"
872
+ readOnly : true
873
+ volumes :
874
+ # mount C:\Data\foo from the host, but only if that directory already exists
875
+ - name : example-volume
876
+ hostPath :
877
+ path : " C:\\ Data\\ foo" # directory location on host
878
+ type : Directory # this field is optional
843
879
-->
844
880
{{< tab name="Windows 节点" codelang="yaml" >}}
845
881
---
@@ -899,7 +935,34 @@ Here's the example manifest:
899
935
以下是清单示例:
900
936
901
937
<!--
902
- # Ensure the file directory is created.
938
+ ` ` ` yaml
939
+ apiVersion: v1
940
+ kind: Pod
941
+ metadata:
942
+ name: test-webserver
943
+ spec:
944
+ os: { name: linux }
945
+ nodeSelector:
946
+ kubernetes.io/os: linux
947
+ containers:
948
+ - name: test-webserver
949
+ image: registry.k8s.io/test-webserver:latest
950
+ volumeMounts:
951
+ - mountPath: /var/local/aaa
952
+ name: mydir
953
+ - mountPath: /var/local/aaa/1.txt
954
+ name: myfile
955
+ volumes:
956
+ - name: mydir
957
+ hostPath:
958
+ # Ensure the file directory is created.
959
+ path: /var/local/aaa
960
+ type: DirectoryOrCreate
961
+ - name: myfile
962
+ hostPath:
963
+ path: /var/local/aaa/1.txt
964
+ type: FileOrCreate
965
+ ` ` `
903
966
-->
904
967
` ` ` yaml
905
968
apiVersion: v1
@@ -1307,7 +1370,25 @@ Here is an example Pod referencing a pre-provisioned Portworx volume:
1307
1370
下面是一个引用预先配备的 Portworx 卷的示例 Pod:
1308
1371
1309
1372
<!--
1310
- # This Portworx volume must already exist.
1373
+ ` ` ` yaml
1374
+ apiVersion: v1
1375
+ kind: Pod
1376
+ metadata:
1377
+ name: test-portworx-volume-pod
1378
+ spec:
1379
+ containers:
1380
+ - image: registry.k8s.io/test-webserver
1381
+ name: test-container
1382
+ volumeMounts:
1383
+ - mountPath: /mnt
1384
+ name: pxvol
1385
+ volumes:
1386
+ - name: pxvol
1387
+ # This Portworx volume must already exist.
1388
+ portworxVolume:
1389
+ volumeID: "pxvol"
1390
+ fsType: "<fs-type>"
1391
+ ` ` `
1311
1392
-->
1312
1393
` ` ` yaml
1313
1394
apiVersion: v1
@@ -1432,7 +1513,7 @@ receive Secret updates.
1432
1513
<!--
1433
1514
For more details, see [Configuring Secrets](/docs/concepts/configuration/secret/).
1434
1515
-->
1435
- 更多详情请参考[配置 Secrets ](/zh-cn/docs/concepts/configuration/secret/)。
1516
+ 更多详情请参考[配置 Secret ](/zh-cn/docs/concepts/configuration/secret/)。
1436
1517
1437
1518
<!--
1438
1519
# ## vsphereVolume (deprecated) {#vspherevolume}
@@ -1612,7 +1693,33 @@ The host directory `/var/log/pods/pod1` is mounted at `/logs` in the container.
1612
1693
宿主机目录 `/var/log/pods/pod1` 被挂载到容器的 `/logs` 中。
1613
1694
1614
1695
<!--
1615
- # The variable expansion uses round brackets (not curly brackets).
1696
+ ` ` ` yaml
1697
+ apiVersion: v1
1698
+ kind: Pod
1699
+ metadata:
1700
+ name: pod1
1701
+ spec:
1702
+ containers:
1703
+ - name: container1
1704
+ env:
1705
+ - name: POD_NAME
1706
+ valueFrom:
1707
+ fieldRef:
1708
+ apiVersion: v1
1709
+ fieldPath: metadata.name
1710
+ image: busybox:1.28
1711
+ command: [ "sh", "-c", "while [ true ]; do echo 'Hello'; sleep 10; done | tee -a /logs/hello.txt" ]
1712
+ volumeMounts:
1713
+ - name: workdir1
1714
+ mountPath: /logs
1715
+ # The variable expansion uses round brackets (not curly brackets).
1716
+ subPathExpr: $(POD_NAME)
1717
+ restartPolicy: Never
1718
+ volumes:
1719
+ - name: workdir1
1720
+ hostPath:
1721
+ path: /var/log/pods
1722
+ ` ` `
1616
1723
-->
1617
1724
` ` ` yaml
1618
1725
apiVersion: v1
0 commit comments