news 2026/4/29 4:38:01

130. 在 RKE1 和 RKE2 的 Kubernetes 集群中,通过负载均衡服务暴露 ingress-nginx 控制器

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
130. 在 RKE1 和 RKE2 的 Kubernetes 集群中,通过负载均衡服务暴露 ingress-nginx 控制器
Situation 地理位置

This knowledge base article provides instructions on configuring the ingress controller in Rancher RKE1 and RKE2 Kubernetes clusters to be exposed through a LoadBalancer service instead of the default host ports 80 and 443 on worker nodes. This is particularly useful when running a Kubernetes cluster on a cloud provider that supports automatic configuration and management of LoadBalancer services through Kubernetes's cloud provider integration.
这篇知识库文章提供了如何配置 Rancher RKE1 和 RKE2 Kubernetes 集群的入口控制器,使其通过 LoadBalancer 服务暴露,而不是工作节点默认的主机端口 80 和 443。这在运行支持通过 Kubernetes 云服务商集成自动配置和管理 LoadBalancer 服务的云服务提供商时,尤为有用。

Resolution 结局

Exposing the Ingress Controller with a LoadBalancer Service in:
在以下环境中通过负载均衡服务暴露入口控制器:

RKE1: RKE1:

In RKE1, it is not possible to directly configure the ingress-nginx controller with a LoadBalancer service through the ingress options in the cluster configuration. However, you can manually create a LoadBalancer service as shown below:
在 RKE1 中,无法通过集群配置中的入口选项直接配置 ingress-nginx 控制器与负载均衡器服务。不过,你可以手动创建负载均衡器服务,如下所示:

<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#f3f3f3">apiVersion: v1 kind: Service metadata: name: ingress-nginx-lb namespace: ingress-nginx spec: ports: - name: http port: 80 protocol: TCP targetPort: 80 - name: https port: 443 protocol: TCP targetPort: 443 selector: app: ingress-nginx type: LoadBalancer </span></span></span>

This will create a LoadBalancer service named "ingress-nginx-lb" in the "ingress-nginx" namespace, exposing ports 80 and 443.
这将在“ingress-nginx”命名空间中创建一个名为“ingress-nginx-lb”的负载均衡器服务,暴露端口 80 和 443。

This LoadBalancer service manifest can be added to the cluster via the user addons configuration, as documented at https://rke.docs.rancher.com/config-options/add-ons/user-defined-add-ons, to manage and deploy it alongside the cluster components/upgrades.
该 LoadBalancer 服务清单可以通过用户插件配置添加到集群,如 https://rke.docs.rancher.com/config-options/add-ons/user-defined-add-ons 文档所述,以便与集群组件/升级一同管理和部署。

RKE2: RKE2:

In RKE2, the ingress-nginx controller is managed through a Helm chart, allowing configuration changes using a HelmChartConfig resource. For more information see the following - https://docs.rke2.io/helm#customizing-packaged-components-with-helmchartconfig. Here is an example below of how to achieve this configuration.
在 RKE2 中,入口-nginx 控制器通过 Helm 图表管理,允许使用 HelmChartConfig 资源进行配置更改。更多信息请参见以下内容——https://docs.rke2.io/helm#customizing-packaged-components-with-helmchartconfig。下面是一个实现这种配置的示例。

<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#f3f3f3">apiVersion: <a>This configuration changes the ingress controller from a DaemonSet to a Deployment, sets the number of replicas to 3 for high availability, and updates the service type to LoadBalancer, enabling external access via a cloud load balancer. You should adjust the replica count based on the size and availability requirements of your environment.
该配置将入口控制器从守护进程集改为部署,将副本数量设置为3以实现高可用性,并将服务类型更新为负载均衡器,从而允许通过云负载均衡器进行外部访问。你应根据环境的规模和可用性需求调整副本数量。

For standalone RKE2 clusters, this HelmChartConfig manifest can be defined within the manifests directory on server nodes, as documented at https://docs.rke2.io/helm#customizing-packaged-components-with-helmchartconfig.
对于独立的 RKE2 集群,这个 HelmChartConfig manifest 可以在服务器节点的 manifests 目录中定义,详见 https://docs.rke2.io/helm#customizing-packaged-components-with-helmchartconfig。

For Rancher-provisioned RKE2 clusters, this HelmChartConfig manifest can be defined within the cluster configuration under 'Additional Manifest'.
对于 Rancher 配置的 RKE2 集群,可以在集群配置中的“额外清单”下定义此 HelmChartConfig 清单。

Cause 病因
Additional Information 附加信息
Environment 环境

An RKE or RKE2 cluster deployed with the bundled ingress-nginx ingress controller
随捆绑的 ingress-nginx 入口控制器部署的 RKE 或 RKE2 集群

访问Rancher-K8S解决方案博主,企业合作伙伴 :
https://blog.csdn.net/lidw2009

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/15 0:33:44

IgH EtherCAT Master在工业机器人中的应用:从LinuxCNC配置到机械臂联调

IgH EtherCAT Master在工业机器人中的深度实践&#xff1a;从系统配置到机械臂精准控制 在智能制造浪潮中&#xff0c;工业机器人的运动控制精度直接决定了生产质量。传统脉冲控制方式已难以满足高速高精需求&#xff0c;而基于EtherCAT的实时总线技术正在成为新一代工业机器人…

作者头像 李华
网站建设 2026/4/15 0:32:32

云计算:水电比喻及其在软件测试的专业应用

想象一下&#xff0c;你向父母解释“云计算”时&#xff0c;用了一个简单比喻&#xff1a;它就像家里的水厂和电网。你不需要自己挖井或建发电站&#xff0c;只需打开水龙头或插上电源&#xff0c;就能按需获取水电服务。云计算同样如此——通过互联网提供计算资源&#xff08;…

作者头像 李华
网站建设 2026/4/15 0:32:31

逆向工程师的汇编速成课:如何用5条核心指令理解程序底层逻辑

逆向工程师的汇编速成课&#xff1a;如何用5条核心指令理解程序底层逻辑 逆向工程的世界里&#xff0c;汇编语言就像显微镜下的细胞结构图。去年分析某个勒索软件样本时&#xff0c;我在反编译器中盯着满屏的十六进制代码发呆&#xff0c;直到突然意识到——所有复杂的恶意行为…

作者头像 李华
网站建设 2026/4/16 4:31:52

BugKu渗透测试实战:从弱口令到内网漫游的全过程记录

BugKu渗透测试实战&#xff1a;从弱口令到内网漫游的完整技术拆解 在网络安全领域&#xff0c;渗透测试是检验系统防御能力的有效手段。本文将详细还原一次针对企业官网的渗透测试全过程&#xff0c;从最基础的弱口令突破开始&#xff0c;逐步深入内网核心区域&#xff0c;最终…

作者头像 李华
网站建设 2026/4/16 0:43:04

向量数据库选型与实战:大模型应用落地的核心基建指南

向量数据库选型要点性能与扩展性 评估数据库的查询速度&#xff08;QPS&#xff09;、延迟&#xff08;毫秒级响应&#xff09;以及水平扩展能力。Milvus、Pinecone等支持分布式架构&#xff0c;适合高吞吐场景&#xff1b;Chroma轻量级但扩展性有限。精度与召回率 关注索引算法…

作者头像 李华
网站建设 2026/4/15 0:18:38

魔兽争霸3终极兼容性修复:5大核心功能彻底解决90%游戏问题

魔兽争霸3终极兼容性修复&#xff1a;5大核心功能彻底解决90%游戏问题 【免费下载链接】WarcraftHelper Warcraft III Helper , support 1.20e, 1.24e, 1.26a, 1.27a, 1.27b 项目地址: https://gitcode.com/gh_mirrors/wa/WarcraftHelper 还在为魔兽争霸3启动闪退、画面…

作者头像 李华