@@ -497,7 +497,7 @@ to mount in a Pod. You can specify single or multiple target world wide names (W
497497using the parameter `targetWWNs` in your Volume configuration. If multiple WWNs are specified,
498498targetWWNs expect that those WWNs are from multi-path connections.
499499-->
500- # ## fc ( 光纤通道) {#fc}
500+ # ## fc( 光纤通道) {#fc}
501501
502502` fc` 卷类型允许将现有的光纤通道块存储卷挂载到 Pod 中。
503503可以使用卷配置中的参数 `targetWWNs` 来指定单个或多个目标 WWN(World Wide Names)。
@@ -580,7 +580,7 @@ clones the repo using Git, then mount the
580580` gitRepo` 卷类型已经被弃用。
581581
582582如果需要制备已挂载 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/)中,
584584使用 Git 命令完成仓库的克隆操作,然后将 [EmptyDir](#emptydir) 卷挂载到 Pod 的容器中。
585585
586586---
@@ -591,12 +591,12 @@ You can restrict the use of `gitRepo` volumes in your cluster using
591591[ValidatingAdmissionPolicy](/docs/reference/access-authn-authz/validating-admission-policy/).
592592You can use the following Common Expression Language (CEL) expression as
593593part 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))` .
595595-->
596596你可以使用 [ValidatingAdmissionPolicy](/zh-cn/docs/reference/access-authn-authz/validating-admission-policy/)
597597这类[策略](/zh-cn/docs/concepts/policy/)来限制在你的集群中使用 `gitRepo` 卷。
598598你可以使用以下通用表达语言(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))` 。
600600{{< /warning >}}
601601
602602<!--
@@ -788,19 +788,38 @@ root 身份运行进程,或者修改主机上的文件权限,以便能够从
788788-->
789789# ### hostPath 配置示例
790790
791+ {{< tabs name="hostpath_examples" >}}
792+
791793<!--
792794Linux node
795+ ---
793796# This manifest mounts /data/foo on the host as /foo inside the
794797# single container that runs within the hostpath-example-linux Pod.
795798#
796799# 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
802821-->
803- {{< tabs name="hostpath_examples" >}}
822+
804823{{< tab name="Linux 节点" codelang="yaml" >}}
805824---
806825# 此清单将主机上的 /data/foo 挂载为 hostpath-example-linux Pod 中运行的单个容器内的 /foo
@@ -831,15 +850,32 @@ spec:
831850
832851<!--
833852Windows node
853+ ---
834854# This manifest mounts C:\Data\foo on the host as C:\foo, inside the
835855# single container that runs within the hostpath-example-windows Pod.
836856#
837857# 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
843879-->
844880{{< tab name="Windows 节点" codelang="yaml" >}}
845881---
@@ -899,7 +935,34 @@ Here's the example manifest:
899935以下是清单示例:
900936
901937<!--
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+ ` ` `
903966-->
904967` ` ` yaml
905968apiVersion: v1
@@ -1307,7 +1370,25 @@ Here is an example Pod referencing a pre-provisioned Portworx volume:
13071370下面是一个引用预先配备的 Portworx 卷的示例 Pod:
13081371
13091372<!--
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+ ` ` `
13111392-->
13121393` ` ` yaml
13131394apiVersion: v1
@@ -1432,7 +1513,7 @@ receive Secret updates.
14321513<!--
14331514For more details, see [Configuring Secrets](/docs/concepts/configuration/secret/).
14341515-->
1435- 更多详情请参考[配置 Secrets ](/zh-cn/docs/concepts/configuration/secret/)。
1516+ 更多详情请参考[配置 Secret ](/zh-cn/docs/concepts/configuration/secret/)。
14361517
14371518<!--
14381519# ## vsphereVolume (deprecated) {#vspherevolume}
@@ -1612,7 +1693,33 @@ The host directory `/var/log/pods/pod1` is mounted at `/logs` in the container.
16121693宿主机目录 `/var/log/pods/pod1` 被挂载到容器的 `/logs` 中。
16131694
16141695<!--
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+ ` ` `
16161723-->
16171724` ` ` yaml
16181725apiVersion: v1
0 commit comments