kube-proxy: Failed to load kernel module ip_vs with modprobe.

偶遇 kube-proxy ipvs 模式不能正常工作,报错如下:

W0301 09:14:39.492670       1 proxier.go:498] Failed to load kernel module ip_vs with modprobe. You can ignore this message when kube-proxy is running inside container without mounting /lib/modules
W0301 09:14:39.493401       1 proxier.go:498] Failed to load kernel module ip_vs_rr with modprobe. You can ignore this message when kube-proxy is running inside container without mounting /lib/modules
W0301 09:14:39.494103       1 proxier.go:498] Failed to load kernel module ip_vs_wrr with modprobe. You can ignore this message when kube-proxy is running inside container without mounting /lib/modules
W0301 09:14:39.494841       1 proxier.go:498] Failed to load kernel module ip_vs_sh with modprobe. You can ignore this message when kube-proxy is running inside container without mounting /lib/modules
W0301 09:14:39.500439       1 proxier.go:498] Failed to load kernel module ip_vs with modprobe. You can ignore this message when kube-proxy is running inside container without mounting /lib/modules
W0301 09:14:39.501168       1 proxier.go:498] Failed to load kernel module ip_vs_rr with modprobe. You can ignore this message when kube-proxy is running inside container without mounting /lib/modules
W0301 09:14:39.501883       1 proxier.go:498] Failed to load kernel module ip_vs_wrr with modprobe. You can ignore this message when kube-proxy is running inside container without mounting /lib/modules
W0301 09:14:39.502612       1 proxier.go:498] Failed to load kernel module ip_vs_sh with modprobe. You can ignore this message when kube-proxy is running inside container without mounting /lib/modules

这是由于 kube-proxy 容器没能自动挂载宿主机内核模块导致的。

可以手动在宿主机执行命令,挂载需要的内核模块:

[root@machine ~]# modprobe ip_vs
[root@machine ~]# modprobe ip_vs_rr
[root@machine ~]# modprobe ip_vs_wrr
[root@machine ~]# modprobe ip_vs_sh

然后,重启 kube-proxy,发现已经没有原来的警告,且工作在 ipvs 代理模式了

I0301 09:19:09.567473       1 server_others.go:176] Using ipvs Proxier.
W0301 09:19:09.567860       1 proxier.go:380] clusterCIDR not specified, unable to distinguish between internal and external traffic
W0301 09:19:09.567872       1 proxier.go:386] IPVS scheduler not specified, use rr by default
I0301 09:19:09.568520       1 server.go:562] Version: v1.14.2
I0301 09:19:09.580637       1 conntrack.go:52] Setting nf_conntrack_max to 131072
I0301 09:19:09.582465       1 config.go:102] Starting endpoints config controller
I0301 09:19:09.582487       1 controller_utils.go:1027] Waiting for caches to sync for endpoints config controller
I0301 09:19:09.582549       1 config.go:202] Starting service config controller
I0301 09:19:09.582557       1 controller_utils.go:1027] Waiting for caches to sync for service config controller
I0301 09:19:09.682604       1 controller_utils.go:1034] Caches are synced for service config controller
I0301 09:19:09.682604       1 controller_utils.go:1034] Caches are synced for endpoints config controller
<think>好的,我现在需要处理用户的问题:“请使用中文回答我或者给我介绍一下: kube-proxy healthzBindAddress:”。首先,用户询问的是kube-proxy中的healthzBindAddress参数。我需要先回忆一下这个参数的作用和配置方式。 首先,kube-proxyKubernetes中的一个核心组件,负责处理节点上的网络规则,确保Pod之间的通信正常。healthzBindAddress应该和健康检查相关,可能用于指定kube-proxy的healthz端点监听的地址和端口。用户可能遇到了配置问题,或者想了解如何调整这个参数。 接下来,我需要确认healthzBindAddress的具体定义。查阅Kubernetes文档,发现kube-proxy的配置中确实有这个参数。它的作用是定义healthz服务器的绑定地址,默认情况下可能是0.0.0.0:10256。用户可能想修改这个地址,或者遇到了与该地址相关的错误,比如端口冲突或无法访问健康检查端点。 然后,我需要考虑用户可能的场景。比如,用户可能在配置kube-proxy时遇到了需要更改默认端口的情况,或者他们的环境中有安全策略限制,只能监听特定IP地址。此外,用户可能看到相关日志或错误信息,需要了解如何正确配置这个参数。 接下来,我需要组织回答的结构。应该先解释healthzBindAddress的作用,然后说明默认值,接着给出配置示例,可能还需要提到相关参数如healthzPort,最后涉及常见问题排查步骤,比如检查端口冲突或防火墙设置。 另外,用户之前的提问是关于“Waiting for caches to sync for node config”,而这次的问题是关于另一个配置参数,可能用户正在深入调试kube-proxy的问题,或者在学习如何配置不同的参数。因此,回答需要详细但保持清晰,帮助用户逐步理解参数的作用和配置方法。 需要确保回答中使用正确的术语,并且符合中文表达习惯。同时,按照用户之前的系统级指令,数学公式或代码块需要使用正确的格式,比如用反引号包裹命令,配置示例用代码块展示。 可能还需要注意,用户是否需要区分旧版本和新版本的kube-proxy配置方式,比如有些参数可能在较新的Kubernetes版本中有所变化。因此,在回答中需要指出版本差异,或者建议用户查阅对应版本的文档。 最后,检查是否有遗漏的重要信息,比如如何验证配置是否生效,如何检查healthz端点的状态,以及相关的日志位置。这些都能帮助用户实际应用配置并进行故障排除。</think>--- ### 关于 `kube-proxy` 的 `healthzBindAddress` 配置参数 `healthzBindAddress` 是 `kube-proxy` 组件中用于定义健康检查(`/healthz` 端点)监听地址的配置参数。它在 **Kubernetes 网络代理层**中起到关键作用,直接影响 `kube-proxy` 的健康状态监控和存活探测功能。 --- #### 1. **参数作用** - **健康检查端点**:`kube-proxy` 通过 `healthzBindAddress` 绑定的地址和端口提供 `/healthz` HTTP 接口,供 Kubernetes 或其他监控工具检查其运行状态。 - **存活探测**:Kubernetes 依赖此端点判断 `kube-proxy` 是否存活,若检测失败可能触发组件重启。 - **安全隔离**:通过绑定到特定 IP(如 `127.0.0.1`),可限制健康检查端点的访问范围,避免暴露到公网。 --- #### 2. **默认值与格式** - **默认值**: `healthzBindAddress: 0.0.0.0:10256` - `0.0.0.0`:监听所有网络接口。 - `10256`:默认端口。 - **格式**: `<IP>:<PORT>` 或 `<IP>`(省略端口时默认用 `10256`)。 --- #### 3. **配置方式** - **通过配置文件**(推荐): 修改 `kube-proxy` 的配置文件(通常为 `/var/lib/kube-proxy/config.conf`),例如: ```yaml apiVersion: kubeproxy.config.k8s.io/v1alpha1 kind: KubeProxyConfiguration healthzBindAddress: 127.0.0.1:10256 # 绑定到本地回环地址 metricsBindAddress: 0.0.0.0:10249 # 监控指标地址(独立配置) ``` - **通过命令行参数**(旧版本兼容): 在 `kube-proxy` 启动命令中直接指定: ```bash kube-proxy --healthz-bind-address=127.0.0.1:8080 ``` --- #### 4. **典型场景与调整建议** ##### **场景 1:端口冲突** - **问题**:若默认端口 `10256` 被其他进程占用,`kube-proxy` 将启动失败。 - **解决**:修改端口并重启服务: ```yaml healthzBindAddress: 0.0.0.0:10257 # 更换端口 ``` ##### **场景 2:安全加固** - **需求**:限制 `healthz` 端点仅允许本地访问。 - **配置**: ```yaml healthzBindAddress: 127.0.0.1:10256 # 仅监听本地回环 ``` ##### **场景 3:IPv6 环境** - **配置**: ```yaml healthzBindAddress: "[fd00::1]:10256" # IPv6 地址需用方括号包裹 ``` --- #### 5. **验证配置生效** - **检查监听端口**: ```bash ss -tuln | grep 10256 # 确认端口已绑定到指定地址 ``` - **访问健康检查端点**: ```bash curl http://127.0.0.1:10256/healthz # 预期返回 "ok" ``` - **查看日志**: ```bash journalctl -u kube-proxy | grep "Serving healthz" # 正常日志示例: # I0701 10:00:00.000000 1 server.go:710] Serving healthz on 127.0.0.1:10256 ``` --- #### 6. **常见问题排查** - **问题:`/healthz` 返回超时或无响应** - 检查 `kube-proxy` 是否运行:`systemctl status kube-proxy` - 确认配置文件中 `healthzBindAddress` 的格式正确(无拼写错误)。 - **问题:端口被拒绝(`Connection refused`)** - 防火墙是否放行该端口?例如: ```bash iptables -L -n | grep 10256 ``` - 是否配置了仅本地访问(`127.0.0.1`)但尝试从外部连接? --- #### 7. **相关参数** - **`metricsBindAddress`**:监控指标端点(如 Prometheus 数据抓取)。 - **`bindAddress`**:kube-proxy 服务监听的通用地址(旧版本参数,部分场景仍生效)。 --- ### 总结 - **关键作用**:`healthzBindAddress` 控制健康检查端点的监听行为,直接影响组件可用性监控。 - **调整原则**:根据安全需求(如网络隔离)和端口冲突情况灵活配置。 - **验证步骤**:检查端口监听状态和直接访问 `/healthz` 端点。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值