diff --git a/content/zh-cn/docs/concepts/scheduling-eviction/resource-bin-packing.md b/content/zh-cn/docs/concepts/scheduling-eviction/resource-bin-packing.md index 6b25f6f80f..42b35709b2 100644 --- a/content/zh-cn/docs/concepts/scheduling-eviction/resource-bin-packing.md +++ b/content/zh-cn/docs/concepts/scheduling-eviction/resource-bin-packing.md @@ -17,75 +17,119 @@ weight: 80 -{{< feature-state for_k8s_version="1.16" state="alpha" >}} - - -使用 `RequestedToCapacityRatioResourceAllocation` 优先级函数,可以将 kube-scheduler -配置为支持包含扩展资源在内的资源装箱操作。 -优先级函数可用于根据自定义需求微调 kube-scheduler 。 +在 kube-scheduler 的[调度插件](/zh-cn/docs/reference/scheduling/config/#scheduling-plugins) +`NodeResourcesFit` 中存在两种支持资源装箱(bin packing)的策略:`MostAllocated` 和 +`RequestedToCapacityRatio`。 +## 使用 MostAllocated 策略启用资源装箱 {#enabling-bin-packing-using-mostallocated-strategy} -## 使用 RequestedToCapacityRatioResourceAllocation 启用装箱 +`MostAllocated` 策略基于资源的利用率来为节点计分,优选分配比率较高的节点。 +针对每种资源类型,你可以设置一个权重值以改变其对节点得分的影响。 -Kubernetes 允许用户指定资源以及每类资源的权重, -以便根据请求数量与可用容量之比率为节点评分。 -这就使得用户可以通过使用适当的参数来对扩展资源执行装箱操作,从而提高了大型集群中稀缺资源的利用率。 -`RequestedToCapacityRatioResourceAllocation` 优先级函数的行为可以通过名为 -`RequestedToCapacityRatioArgs` 的配置选项进行控制。 -该标志由两个参数 `shape` 和 `resources` 组成。 -`shape` 允许用户根据 `utilization` 和 `score` 值将函数调整为 -最少请求(least requested)或最多请求(most requested)计算。 -`resources` 包含由 `name` 和 `weight` 组成,`name` 指定评分时要考虑的资源, -`weight` 指定每种资源的权重。 - - - -以下是一个配置示例,该配置将 `requestedToCapacityRatioArguments` 设置为对扩展资源 -`intel.com/foo` 和 `intel.com/bar` 的装箱行为 +要为插件 `NodeResourcesFit` 设置 `MostAllocated` 策略, +可以使用一个类似于下面这样的[调度器配置](/zh-cn/docs/reference/scheduling/config/): ```yaml apiVersion: kubescheduler.config.k8s.io/v1beta3 kind: KubeSchedulerConfiguration profiles: -# ... - pluginConfig: - - name: RequestedToCapacityRatio - args: - shape: - - utilization: 0 - score: 10 - - utilization: 100 - score: 0 - resources: - - name: intel.com/foo - weight: 3 - - name: intel.com/bar - weight: 5 +- pluginConfig: + - args: + scoringStrategy: + resources: + - name: cpu + weight: 1 + - name: memory + weight: 1 + - name: intel.com/foo + weight: 3 + - name: intel.com/bar + weight: 3 + type: MostAllocated + name: NodeResourcesFit +``` + + +要进一步了解其它参数及其默认配置,请参阅 +[`NodeResourcesFitArgs`](/zh-cn/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-NodeResourcesFitArgs) +的 API 文档。 + + +## 使用 RequestedToCapacityRatio 策略来启用资源装箱 {#enabling-bin-packing-using-requestedtocapacityratio} + +`RequestedToCapacityRatio` 策略允许用户基于请求值与容量的比率,针对参与节点计分的每类资源设置权重。 +这一策略是的用户可以使用合适的参数来对扩展资源执行装箱操作,进而提升大规模集群中稀有资源的利用率。 +此策略根据所分配资源的一个配置函数来评价节点。 +`NodeResourcesFit` 计分函数中的 `RequestedToCapacityRatio` 可以通过字段 +[scoringStrategy](/zh-cn/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-ScoringStrategy) +来控制。 +在 `scoringStrategy` 字段中,你可以配置两个参数:`requestedToCapacityRatioParam` +和 `resources`。`requestedToCapacityRatioParam` 参数中的 `shape` +设置使得用户能够调整函数的算法,基于 `utilization` 和 `score` 值计算最少请求或最多请求。 +`resources` 参数中包含计分过程中需要考虑的资源的 `name`,以及用来设置每种资源权重的 `weight`。 + + +下面是一个配置示例,使用 `requestedToCapacityRatio` 字段为扩展资源 `intel.com/foo` +和 `intel.com/bar` 设置装箱行为: + +```yaml +apiVersion: kubescheduler.config.k8s.io/v1beta3 +kind: KubeSchedulerConfiguration +profiles: +- pluginConfig: + - args: + scoringStrategy: + resources: + - name: intel.com/foo + weight: 3 + - name: intel.com/bar + weight: 3 + requestedToCapacityRatioParam: + shape: + - utilization: 0 + score: 0 + - utilization: 100 + score: 10 + type: RequestedToCapacityRatio + name: NodeResourcesFit ``` 使用 kube-scheduler 标志 `--config=/path/to/config/file` -引用 `KubeSchedulerConfiguration` 文件将配置传递给调度器。 +引用 `KubeSchedulerConfiguration` 文件,可以将配置传递给调度器。 - -**默认情况下此功能处于被禁用状态** +要进一步了解其它参数及其默认配置,可以参阅 +[`NodeResourcesFitArgs`](/zh-cn/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-NodeResourcesFitArgs) +的 API 文档。 -### 调整 RequestedToCapacityRatioResourceAllocation 优先级函数 +### 调整计分函数 {#tuning-the-score-function} -`shape` 用于指定 `RequestedToCapacityRatioPriority` 函数的行为。 +`shape` 用于指定 `RequestedToCapacityRatio` 函数的行为。 ```yaml shape: @@ -120,9 +166,10 @@ shape: ``` - 上面的参数在 `utilization` 为 0% 时给节点评分为 0,在 `utilization` 为 100% 时给节点评分为 10,因此启用了装箱行为。 要启用最少请求(least requested)模式,必须按如下方式反转得分值。 @@ -151,7 +198,7 @@ resources: -它可以用来添加扩展资源,如下所示: +它可以像下面这样用来添加扩展资源: ```yaml resources: @@ -164,10 +211,11 @@ resources: ``` -weight 参数是可选的,如果未指定,则设置为 1。 -同时,weight 不能设置为负值。 +`weight` 参数是可选的,如果未指定,则设置为 1。 +同时,`weight` 不能设置为负值。 - -### 节点容量分配的评分 +### 节点容量分配的评分 {#node-scoring-for-capacity-allocation} 本节适用于希望了解此功能的内部细节的人员。 以下是如何针对给定的一组值来计算节点得分的示例。 -``` -请求的资源 + +请求的资源: +``` intel.com/foo : 2 memory: 256MB cpu: 2 +``` -资源权重 + +资源权重: +``` intel.com/foo : 5 memory: 1 cpu: 3 +``` +``` FunctionShapePoint {{0, 0}, {100, 10}} +``` -节点 Node 1 配置 + +节点 1 配置: +``` 可用: intel.com/foo : 4 memory : 1 GB @@ -208,34 +270,43 @@ FunctionShapePoint {{0, 0}, {100, 10}} intel.com/foo: 1 memory: 256MB cpu: 1 +``` + 节点得分: +``` intel.com/foo = resourceScoringFunction((2+1),4) = (100 - ((4-3)*100/4) = (100 - 25) - = 75 - = rawScoringFunction(75) - = 7 + = 75 # requested + used = 75% * available + = rawScoringFunction(75) + = 7 # floor(75/10) memory = resourceScoringFunction((256+256),1024) = (100 -((1024-512)*100/1024)) - = 50 + = 50 # requested + used = 50% * available = rawScoringFunction(50) - = 5 + = 5 # floor(50/10) cpu = resourceScoringFunction((2+1),8) = (100 -((8-3)*100/8)) - = 37.5 + = 37.5 # requested + used = 37.5% * available = rawScoringFunction(37.5) - = 3 + = 3 # floor(37.5/10) NodeScore = (7 * 5) + (5 * 1) + (3 * 3) / (5 + 1 + 3) = 5 +``` + +节点 2 配置: -节点 Node 2 配置 - +``` 可用: intel.com/foo: 8 memory: 1GB @@ -245,9 +316,14 @@ NodeScore = (7 * 5) + (5 * 1) + (3 * 3) / (5 + 1 + 3) intel.com/foo: 2 memory: 512MB cpu: 6 +``` + 节点得分: +``` intel.com/foo = resourceScoringFunction((2+2),8) = (100 - ((8-4)*100/8) = (100 - 50) @@ -270,3 +346,13 @@ cpu = resourceScoringFunction((2+6),8) NodeScore = (5 * 5) + (7 * 1) + (10 * 3) / (5 + 1 + 3) = 7 ``` + +## {{% heading "whatsnext" %}} + + +- 继续阅读[调度器框架](/zh-cn/docs/concepts/scheduling-eviction/scheduling-framework/) +- 继续阅读[调度器配置](/zh-cn/docs/reference/scheduling/config/) + diff --git a/content/zh-cn/docs/concepts/storage/persistent-volumes.md b/content/zh-cn/docs/concepts/storage/persistent-volumes.md index 96c585fb72..e9b5ccc140 100644 --- a/content/zh-cn/docs/concepts/storage/persistent-volumes.md +++ b/content/zh-cn/docs/concepts/storage/persistent-volumes.md @@ -1012,6 +1012,23 @@ In the CLI, the access modes are abbreviated to: * RWX - ReadWriteMany * RWOP - ReadWriteOncePod +{{< note >}} + +Kubernetes 使用卷访问模式来匹配 PersistentVolumeClaim 和 PersistentVolume。 +在某些场合下,卷访问模式也会限制 PersistentVolume 可以挂载的位置。 +卷访问模式并**不会**在存储已经被挂载的情况下为其实施写保护。 +即使访问模式设置为 ReadWriteOnce、ReadOnlyMany 或 ReadWriteMany,它们也不会对卷形成限制。 +例如,即使某个卷创建时设置为 ReadOnlyMany,也无法保证该卷是只读的。 +如果访问模式设置为 ReadWriteOncePod,则卷会被限制起来并且只能挂载到一个 Pod 上。 +{{< /note >}} + @@ -1821,11 +1838,11 @@ and need persistent storage, it is recommended that you use the following patter * 进一步了解[创建持久卷](/zh/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolume). * 进一步学习[创建 PVC 申领](/zh/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolumeclaim). -* 阅读[持久存储的设计文档](https://git.k8s.io/community/contributors/design-proposals/storage/persistent-storage.md). +* 阅读[持久存储的设计文档](https://github.com/kubernetes/design-proposals-archive/blob/main/storage/persistent-storage.md). Container 中的文件在磁盘上是临时存放的,这给 Container 中运行的较重要的应用程序带来一些问题。 问题之一是当容器崩溃时文件丢失。 @@ -33,10 +34,7 @@ kubelet 会重新启动容器,但容器会以干净的状态重启。 Kubernetes {{< glossary_tooltip text="卷(Volume)" term_id="volume" >}} 这一抽象概念能够解决这两个问题。 - -阅读本文前建议你熟悉一下 [Pods](/zh/docs/concepts/workloads/pods)。 +阅读本文前建议你熟悉一下 [Pod](/zh-cn/docs/concepts/workloads/pods)。 @@ -120,15 +118,21 @@ Kubernetes supports several types of Volumes: Kubernetes 支持下列类型的卷: -### awsElasticBlockStore {#awselasticblockstore} - +### awsElasticBlockStore (已弃用) {#awselasticblockstore} + +{{< feature-state for_k8s_version="v1.17" state="deprecated" >}} + `awsElasticBlockStore` 卷将 Amazon Web服务(AWS)[EBS 卷](https://aws.amazon.com/ebs/) 挂载到你的 Pod 中。与 `emptyDir` 在 Pod 被删除时也被删除不同,EBS 卷的内容在删除 Pod 时会被保留,卷只是被卸载掉了。 @@ -239,13 +243,18 @@ and the kubelet, set the `InTreePluginAWSUnregister` flag to `true`. 要禁止控制器管理器和 kubelet 加载 `awsElasticBlockStore` 存储插件, 请将 `InTreePluginAWSUnregister` 标志设置为 `true`。 -### azureDisk {#azuredisk} - +### azureDisk (已弃用) {#azuredisk} + +{{< feature-state for_k8s_version="v1.19" state="deprecated" >}} `azureDisk` 卷类型用来在 Pod 上挂载 Microsoft Azure [数据盘(Data Disk)](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-about-disks-vhds/) 。 @@ -287,14 +296,20 @@ and the kubelet, set the `InTreePluginAzureDiskUnregister` flag to `true`. 要禁止控制器管理器和 kubelet 加载 `azureDisk` 存储插件, 请将 `InTreePluginAzureDiskUnregister` 标志设置为 `true`。 -### azureFile {#azurefile} - +### azureFile (已弃用) {#azurefile} + +{{< feature-state for_k8s_version="v1.21" state="deprecated" >}} + `azureFile` 卷类型用来在 Pod 上挂载 Microsoft Azure 文件卷(File Volume)(SMB 2.1 和 3.0)。 更多详情请参考 [`azureFile` 卷插件](https://github.com/kubernetes/examples/tree/master/staging/volumes/azure_file/README.md)。 @@ -370,23 +385,29 @@ See the [CephFS example](https://github.com/kubernetes/examples/tree/master/volu --> 更多信息请参考 [CephFS 示例](https://github.com/kubernetes/examples/tree/master/volumes/cephfs/)。 -### cinder {#cinder} + +### cinder (已弃用) {#cinder} +{{< feature-state for_k8s_version="v1.18" state="deprecated" >}} + +{{< note >}} -{{< note >}} Kubernetes 必须配置了 OpenStack Cloud Provider。 {{< /note >}} `cinder` 卷类型用于将 OpenStack Cinder 卷挂载到 Pod 中。 -#### Cinder 卷示例配置 + +#### Cinder 卷示例配置 {#cinder-volume-example-configuration} ```yaml apiVersion: v1 @@ -2102,12 +2123,38 @@ for more information. 进一步的信息可参阅[临时卷](/zh/docs/concepts/storage/ephemeral-volumes/#csi-ephemeral-volume)。 有关如何开发 CSI 驱动的更多信息,请参考 [kubernetes-csi 文档](https://kubernetes-csi.github.io/docs/)。 + +#### Windows CSI 代理 {#windows-csi-proxy} + +{{< feature-state for_k8s_version="v1.22" state="stable" >}} + + +CSI 节点插件需要执行多种特权操作,例如扫描磁盘设备和挂载文件系统等。 +这些操作在每个宿主操作系统上都是不同的。对于 Linux 工作节点而言,容器化的 CSI +节点插件通常部署为特权容器。对于 Windows 工作节点而言,容器化 CSI +节点插件的特权操作是通过 [csi-proxy](https://github.com/kubernetes-csi/csi-proxy) +来支持的。csi-proxy 是一个由社区管理的、独立的可执行二进制文件, +需要被预安装到每个 Windows 节点上。 + +要了解更多的细节,可以参考你要部署的 CSI 插件的部署指南。 + @@ -2124,9 +2171,6 @@ configuration changes to existing Storage Classes, PersistentVolumes or Persiste The operations and features that are supported include: provisioning/delete, attach/detach, mount/unmount and resizing of volumes. - -In-tree plugins that support `CSIMigration` and have a corresponding CSI driver implemented -are listed in [Types of Volumes](#volume-types). --> 启用 `CSIMigration` 特性后,针对现有树内插件的操作会被重定向到相应的 CSI 插件(应已安装和配置)。 因此,操作员在过渡到取代树内插件的 CSI 驱动时,无需对现有存储类、PV 或 PVC(指树内插件)进行任何配置更改。 @@ -2134,9 +2178,23 @@ are listed in [Types of Volumes](#volume-types). 所支持的操作和特性包括:配备(Provisioning)/删除、挂接(Attach)/解挂(Detach)、 挂载(Mount)/卸载(Unmount)和调整卷大小。 + 上面的[卷类型](#volume-types)节列出了支持 `CSIMigration` 并已实现相应 CSI 驱动程序的树内插件。 +下面是支持 Windows 节点上持久性存储的树内插件: + +* [`awsElasticBlockStore`](#awselasticblockstore) +* [`azureDisk`](#azuredisk) +* [`azureFile`](#azurefile) +* [`gcePersistentDisk`](#gcepersistentdisk) +* [`vsphereVolume`](#vspherevolume) + ### flexVolume {{< feature-state for_k8s_version="v1.23" state="deprecated" >}} @@ -2156,14 +2214,24 @@ FlexVolume 是一个使用基于 exec 的模型来与驱动程序对接的树外 Pod 通过 `flexvolume` 树内插件与 FlexVolume 驱动程序交互。 更多详情请参考 FlexVolume [README](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-storage/flexvolume.md#readme) 文档。 + +下面的 FlexVolume [插件](https://github.com/Microsoft/K8s-Storage-Plugins/tree/master/flexvolume/windows) +以 PowerShell 脚本的形式部署在宿主系统上,支持 Windows 节点: + +* [SMB](https://github.com/microsoft/K8s-Storage-Plugins/tree/master/flexvolume/windows/plugins/microsoft.com~smb.cmd) +* [iSCSI](https://github.com/microsoft/K8s-Storage-Plugins/tree/master/flexvolume/windows/plugins/microsoft.com~iscsi.cmd) + +{{< note >}} -{{< note >}} -FlexVolume 已弃用。推荐使用树外 CSI 驱动来将外部存储整合进 Kubernetes。 +FlexVolume 已被弃用。推荐使用树外 CSI 驱动来将外部存储整合进 Kubernetes。 FlexVolume 驱动的维护者应开发一个 CSI 驱动并帮助用户从 FlexVolume 驱动迁移到 CSI。 FlexVolume 用户应迁移工作负载以使用对等的 CSI 驱动。 @@ -2288,10 +2356,8 @@ sudo systemctl restart docker ## {{% heading "whatsnext" %}} - - 参考[使用持久卷部署 WordPress 和 MySQL](/zh/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/) 示例。