From 29714842992691956d829bf9c6f37fdd6b511331 Mon Sep 17 00:00:00 2001 From: chentanjun <2799194073@qq.com> Date: Thu, 2 Jan 2020 13:21:40 +0800 Subject: [PATCH] update zh-trans:content/zh/docs/setup/production-environment/windows/user-guide-windows-containers.md (#18351) --- .../windows/user-guide-windows-containers.md | 140 +++++++++++++++++- 1 file changed, 132 insertions(+), 8 deletions(-) diff --git a/content/zh/docs/setup/production-environment/windows/user-guide-windows-containers.md b/content/zh/docs/setup/production-environment/windows/user-guide-windows-containers.md index 5c14606b86..74790f03c9 100644 --- a/content/zh/docs/setup/production-environment/windows/user-guide-windows-containers.md +++ b/content/zh/docs/setup/production-environment/windows/user-guide-windows-containers.md @@ -208,13 +208,13 @@ Users can ensure Windows containers can be scheduled on the appropriate host usi --> 用户可以使用污点和容忍度确保 Windows 容器可以调度在适当的主机上。目前所有 Kubernetes 节点都具有以下默认标签: -* beta.kubernetes.io/os = [windows|linux] -* beta.kubernetes.io/arch = [amd64|arm64|...] +* kubernetes.io/os = [windows|linux] +* kubernetes.io/arch = [amd64|arm64|...] -如果 Pod 规范未指定诸如 `"beta.kubernetes.io/os": windows` 之类的 nodeSelector,则该 Pod 可能会被调度到任何主机(Windows 或 Linux)上。这是有问题的,因为 Windows 容器只能在 Windows 上运行,而 Linux 容器只能在 Linux 上运行。最佳实践是使用 nodeSelector。 +如果 Pod 规范未指定诸如 `"kubernetes.io/os": windows` 之类的 nodeSelector,则该 Pod 可能会被调度到任何主机(Windows 或 Linux)上。这是有问题的,因为 Windows 容器只能在 Windows 上运行,而 Linux 容器只能在 Linux 上运行。最佳实践是使用 nodeSelector。 -例如:`--register-with-taints='os=Win1809:NoSchedule'` +例如:`--register-with-taints='os=windows:NoSchedule'` +### 处理同一集群中的多个 Windows 版本 + + +每个 Pod 使用的 Windows Server 版本必须与该节点的 Windows Server 版本相匹配。 +如果要在同一集群中使用多个 Windows Server 版本,则应该设置其他节点标签和 nodeSelector。 + + +Kubernetes 1.17 自动添加了一个新标签 `node.kubernetes.io/windows-build` 来简化此操作。 如果您运行的是旧版本,则建议手动将此标签添加到 Windows 节点。 + + +此标签反映了需要兼容的 Windows 主要、次要和内部版本号。以下是当前每个 Windows Server 版本使用的值。 + +| 产品名称 | 内部编号 | +|--------------------------------------|------------------------| +| Windows Server 2019 | 10.0.17763 | +| Windows Server version 1809 | 10.0.17763 | +| Windows Server version 1903 | 10.0.18362 | + + + +### 使用 RuntimeClass 简化 + + +[RuntimeClass] 可用于简化使用污点和容忍度的过程。集群管理员可以创建 `RuntimeClass` 对象,用于封装这些污点和容忍度。 + + + +1. 将此文件保存到 `runtimeClasses.yml` 文件。它包括适用于 Windows 操作系统、体系结构和版本的 `nodeSelector`。 + +```yaml +apiVersion: node.k8s.io/v1beta1 +kind: RuntimeClass +metadata: + name: windows-2019 +handler: 'docker' +scheduling: + nodeSelector: + kubernetes.io/os: 'windows' + kubernetes.io/arch: 'amd64' + node.kubernetes.io/windows-build: '10.0.17763' + tolerations: + - effect: NoSchedule + key: os + operator: Equal + value: "windows" +``` + + +1. 集群管理员运行 `kubectl create -f runtimeClasses.yml` 操作 +1. 根据需要向 Pod 规约中添加 `runtimeClassName: windows-2019` + + +例如: + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: iis-2019 + labels: + app: iis-2019 +spec: + replicas: 1 + template: + metadata: + name: iis-2019 + labels: + app: iis-2019 + spec: + runtimeClassName: windows-2019 + containers: + - name: iis + image: mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 + resources: + limits: + cpu: 1 + memory: 800Mi + requests: + cpu: .1 + memory: 300Mi + ports: + - containerPort: 80 + selector: + matchLabels: + app: iis-2019 +--- +apiVersion: v1 +kind: Service +metadata: + name: iis +spec: + type: LoadBalancer + ports: + - protocol: TCP + port: 80 + selector: + app: iis-2019 +``` + + {{% /capture %}} + +[RuntimeClass]: https://kubernetes.io/docs/concepts/containers/runtime-class/