diff --git a/content/zh-cn/docs/tasks/debug/debug-cluster/windows.md b/content/zh-cn/docs/tasks/debug/debug-cluster/windows.md index 0dd8dba8e5..ef4f236539 100644 --- a/content/zh-cn/docs/tasks/debug/debug-cluster/windows.md +++ b/content/zh-cn/docs/tasks/debug/debug-cluster/windows.md @@ -1,14 +1,22 @@ --- -title: Windows 调试小技巧 +title: Windows 调试技巧 content_type: concept --- + + + ## 工作节点级别排障 {#troubleshooting-node} 1. 我的 Pod 都卡在 “Container Creating” 或者不断重启 确保你的 pause 镜像跟你的 Windows 版本兼容。 - 查看 [Pause 容器](zh/docs/setup/production-environment/windows/intro-windows-in-kubernetes#pause-container) + 查看 [Pause 容器](/zh-cn/docs/setup/production-environment/windows/intro-windows-in-kubernetes#pause-container) 以了解最新的或建议的 pause 镜像,或者了解更多信息。 {{< note >}} - 如果你使用了 containerd 作为你的容器运行时,pause 镜像在 config.toml 配置文件的 + + 如果你在使用 containerd 作为你的容器运行时,pause 镜像在 config.toml 配置文件的 `plugins.plugins.cri.sandbox_image` 中指定。 {{< /note >}} + -2. 我的 pod 状态显示 'ErrImgPull' 或者 ‘ImagePullBackOff’ +2. 我的 Pod 状态显示 'ErrImgPull' 或者 'ImagePullBackOff' - 保证你的 Pod 被调度到[兼容的](https://docs.microsoft.com/virtualization/windowscontainers/deploy-containers/version-compatibility) Windows 节点上。 + 保证你的 Pod 被调度到[兼容的](https://docs.microsoft.com/virtualization/windowscontainers/deploy-containers/version-compatibility) + Windows 节点上。 关于如何为你的 Pod 指定一个兼容节点, - 的更多信息可以查看这个指可以查看[这个指南](/zh-cn/docs/setup/production-environment/windows/user-guide-windows-containers/#ensuring-os-specific-workloads-land-on-the-appropriate-container-host)以了解更多的信息。 + 可以查看这个指可以查看[这个指南](/zh-cn/docs/setup/production-environment/windows/user-guide-windows-containers/#ensuring-os-specific-workloads-land-on-the-appropriate-container-host) + 以了解更多的信息。 + +2. 我的 Windows Pod 不能 ping 通外界资源 + Windows Pod 没有为 ICMP 协议编写出站规则,但 TCP/UDP 是支持的。当试图演示与集群外部资源的连接时,可以把 `ping ` 替换为 `curl ` 命令。 + + + 如果你仍然遇到问题,很可能你需要额外关注 + [cni.conf](https://github.com/Microsoft/SDN/blob/master/Kubernetes/flannel/l2bridge/cni/config/cni.conf) + 的配置。你可以随时编辑这个静态文件。更新配置将应用于新的 Kubernetes 资源。 + -2. 我的 Windows Pod 不能 ping 通外界资源 - - Windows Pod 没有为 ICMP 协议编写出站规则,但 TCP/UDP 是支持的。当试图演示与集群外部资源的连接时,可以把 `ping ` 替换为 `curl ` 命令。 - - 如果你仍然遇到问题,很可能你需要额外关注 - [cni.conf](https://github.com/Microsoft/SDN/blob/master/Kubernetes/flannel/l2bridge/cni/config/cni.conf) - 的配置。你可以随时编辑这个静态文件。更新配置将应用于新的 Kubernetes 资源。 - + --> Kubernetes 的网络需求之一 (查看 [Kubernetes 模型](/zh-cn/docs/concepts/cluster-administration/networking/)) 是集群通信不需要内部的 NAT。 - 为了遵守这一要求, 对于你不希望发生的出站 NAT 通信,这里有一个 + 为了遵守这一要求,对于你不希望发生的出站 NAT 通信,这里有一个 [ExceptionList](https://github.com/Microsoft/SDN/blob/master/Kubernetes/flannel/l2bridge/cni/config/cni.conf#L20) 。 然而,这也意味着你需要从 `ExceptionList` 中去掉你试图查询的外部IP。 只有这样,来自你的 Windows Pod 的流量才会被正确地 SNAT 转换,以接收来自外部环境的响应。 就此而言,你的 `cni.conf` 中的 `ExceptionList` 应该如下所示: + + + ```conf + "ExceptionList": [ + "10.244.0.0/16", # 集群子网 + "10.96.0.0/12", # 服务子网 + "10.127.130.0/24" # 管理(主机)子网 + ] + ``` +3. 我的 Windows 节点无法访问 `NodePort` 类型 Service -4. vNICs and HNS endpoints of containers are being deleted + 从节点本身访问本地 NodePort 失败,是一个已知的限制。 + 你可以从其他节点或外部客户端正常访问 NodePort。 + + -3. 我的 Windows 节点无法访问 `NodePort` 类型服务 +4. 容器的 vNIC 和 HNS 端点正在被删除 - 从节点本身访问本地 NodePort 失败,是一个已知的限制。你可以从其他节点或外部客户端正常访问 NodePort。 - -4. 容器的 vnic 和 HNS endpoints 正在被删除 - - 当 `hostname-override` 参数没有传递给 [kube-proxy](/zh-cn/docs/reference/command-line-tools-reference/kube-proxy/) + 当 `hostname-override` 参数没有传递给 + [kube-proxy](/zh-cn/docs/reference/command-line-tools-reference/kube-proxy/) 时可能引发这一问题。想要解决这个问题,用户需要将主机名传递给 kube-proxy,如下所示: ```powershell C:\k\kube-proxy.exe --hostname-override=$(hostname) ``` + 5. 我的 Windows 节点无法通过服务 IP 访问我的服务 这是 Windows 上网络栈的一个已知限制。但是 Windows Pod 可以访问 Service IP。 + 6. 启动 kubelet 时找不到网络适配器 Windows 网络栈需要一个虚拟适配器才能使 Kubernetes 网络工作。 @@ -179,39 +190,42 @@ content_type: concept Get-NetAdapter | ? Name -Like "vEthernet (Ethernet*" ``` + 如果主机的网络适配器不是 "Ethernet",通常有必要修改 `start.ps1` 脚本的 - [InterfaceName](https://github.com/microsoft/SDN/blob/master/Kubernetes/flannel/start.ps1#L7) 参数。 - 否则,如果虚拟网络创建过程出错,请检查 `start-kubelet.ps1` 脚本的输出。 + [InterfaceName](https://github.com/microsoft/SDN/blob/master/Kubernetes/flannel/start.ps1#L7) + 参数。否则,如果虚拟网络创建过程出错,请检查 `start-kubelet.ps1` 脚本的输出。 + +7. DNS 解析工作异常 -8. `kubectl port-forward` fails with "unable to do port forwarding: wincat not found" + 查阅[这一节](#dns-limitations)中讲述的 Windows 系统上的 DNS 限制。 + + -7. DNS 解析工作异常 - - 在[本节](#dns-limitations)中了解 Windows 系统上的 DNS 限制。 - 8. `kubectl port-forward` 失败,错误为 "unable to do port forwarding: wincat not found" 在 Kubernetes 1.15 中,pause 基础架构容器 `mcr.microsoft.com/oss/kubernetes/pause:3.6` 中包含 `wincat.exe` 来实现端口转发。 请确保使用 Kubernetes 的受支持版本。如果你想构建自己的 pause 基础架构容器, 请确保其中包含 [wincat](https://github.com/kubernetes/kubernetes/tree/master/build/pause/windows/wincat)。 + 9. 我的 Kubernetes 安装失败,因为我的 Windows 服务器节点使用了代理服务器 @@ -221,6 +235,7 @@ content_type: concept [Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://proxy.example.com:80/", [EnvironmentVariableTarget]::Machine) [Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://proxy.example.com:443/", [EnvironmentVariableTarget]::Machine) ``` + ## Flannel 故障排查 {#troubleshooting-network} @@ -246,43 +256,39 @@ content_type: concept Remove-Item C:\k\SourceVip.json Remove-Item C:\k\SourceVipRequest.json ``` + +2. Flanneld 卡在 "Waiting for the Network to be created" + 关于这个[问题](https://github.com/coreos/flannel/issues/1066)有很多报告; + 很可能是 Flannel 网络管理 IP 的设置时机问题。 + 一个变通方法是重新启动 `start.ps1` 或按如下方式手动重启: + + -2. Flanneld 卡在 "Waiting for the Network to be created" - - 关于这个[问题](https://github.com/coreos/flannel/issues/1066)有很多报告 ; - 很可能是 flannel 网络管理 IP 的设置时机问题。 - 一个变通方法是重新启动 `start.ps1` 或按如下方式手动重启: - + --> ```powershell [Environment]::SetEnvironmentVariable("NODE_NAME", "") C:\flannel\flanneld.exe --kubeconfig-file=c:\k\config --iface= --ip-masq=1 --kube-subnet-mgr=1 ``` + 3. 我的 Windows Pod 无法启动,因为缺少 `/run/flannel/subnet.env` @@ -312,3 +318,4 @@ If these steps don't resolve your problem, you can get help running Windows cont * StackOverflow [Windows Server Container](https://stackoverflow.com/questions/tagged/windows-server-container) topic * Kubernetes 官方论坛 [discuss.kubernetes.io](https://discuss.kubernetes.io/) * Kubernetes Slack [#SIG-Windows Channel](https://kubernetes.slack.com/messages/sig-windows) +