腾讯云容器服务 TKE 现已支持多个 Ingress 复用同一负载均衡器。如需将多个 Ingress 的流量聚合到单一负载均衡器入口,您可以在创建 Ingress 资源时为其添加
ingress.cloud.tencent.com/enable-group: 'true' 注解,并使用 kubernetes.io/ingress.existLbId: lb-xxxxxxxx 注解指向相同的 CLB 实例。注意事项
多个 Ingress 复用同一个 CLB 时,推荐复用同一个 CLB 的 Ingress 数目不大于 100。
此功能必须在创建 Ingress 时启用。对于已创建的 Ingress,暂时不支持追加开启。
不支持复用由 TKE CLB Ingress 自动创建的 CLB。
请注意,多个 Ingress 复用同一个 CLB 可能会创建更多的监听器或转发规则,而 CLB 存在账号和实例维度的配额限制,为避免触达上限影响 Ingress 同步,请联系负载均衡团队 提交工单 以规划合理的配额。
警告:
多个 Ingress 复用 CLB 时,若发生配置冲突,Ingress Controller 将中断调谐并报错,为了避免影响 Ingress 同步规则和配置,请关注 Ingress 并及时处理错误!
使用前提
说明:
Service/Ingress Controller 版本:您可以在 TKE 集群的
kube-system 命名空间下,查看 configmap tke-service-controller-config 和 tke-ingress-controller-config 中的 VERSION 参数,以获取对应组件的版本信息。使用方式
多个 Ingress 可以复用相同的监听器(端口)或域名,但必须确保每个“域名 + URL 路径”的规则组合是唯一的。
支持跨命名空间(Namespace)的多个 Ingress 复用同一个 CLB。
部分功能特性在复用场景下不受支持,相关错误将在 Ingress 事件/注解 中提示。
注意:
注解
ingress.cloud.tencent.com/enable-group: 'true' 需要在创建 Ingress 时与 kubernetes.io/ingress.existLbId: lb-xxxxxxxx 同时指定,对已有 Ingress 添加注解无法启用该功能。前置条件
使用示例
apiVersion: v1kind: Namespacemetadata:name: ns1---apiVersion: v1kind: Namespacemetadata:name: ns2---apiVersion: networking.k8s.io/v1kind: Ingressmetadata:annotations:ingress.cloud.tencent.com/listen-ports: '[{"HTTP": 80}]'kubernetes.io/ingress.existLbId: lb-xxxxxxxx # 请修改成自己的clb idingress.cloud.tencent.com/enable-group: 'true' # 必须在 ingress 创建时指定name: nginx-ingress-1namespace: ns1spec:rules:- http:paths:- backend:service:name: nginx-serviceport:number: 80path: /pathType: ImplementationSpecific---apiVersion: networking.k8s.io/v1kind: Ingressmetadata:annotations:ingress.cloud.tencent.com/listen-ports: '[{"HTTP": 81}]'kubernetes.io/ingress.existLbId: lb-xxxxxxxx # 请修改成自己的clb idingress.cloud.tencent.com/enable-group: 'true'name: nginx-ingress-2namespace: ns2spec:rules:- http:paths:- backend:service:name: nginx-serviceport:number: 80path: /pathType: ImplementationSpecific
apiVersion: v1kind: Namespacemetadata:name: ns1---apiVersion: v1kind: Namespacemetadata:name: ns2---apiVersion: networking.k8s.io/v1kind: Ingressmetadata:annotations:ingress.cloud.tencent.com/listen-ports: '[{"HTTP": 80}]'kubernetes.io/ingress.existLbId: lb-xxxxxxxx # 请修改成自己的clb idingress.cloud.tencent.com/enable-group: 'true' # 必须在新建ingress时和 kubernetes.io/ingress.existLbId 同时指定kubernetes.io/ingress.http-rules: '[{"host":"example.com","path":"/api","backend":{"serviceName":"anyserver","servicePort":"80"}},{"host":"example.com","path":"/tmp","rewrite":{"port":80,"host":"example.com","path":"/api"}}]'kubernetes.io/ingress.https-rules: "null"kubernetes.io/ingress.rule-mix: "true"name: nginx-ingress-1namespace: ns1spec:rules:- http:paths:- backend:service:name: nginx-serviceport:number: 80path: /pathType: ImplementationSpecific---apiVersion: networking.k8s.io/v1kind: Ingressmetadata:annotations:ingress.cloud.tencent.com/listen-ports: '[{"HTTP": 80}]'kubernetes.io/ingress.existLbId: lb-xxxxxxxx # 请修改成自己的clb idingress.cloud.tencent.com/enable-group: 'true'name: nginx-ingress-2namespace: ns2spec:rules:- http:paths:- backend:service:name: nginx-serviceport:number: 80path: /homepathType: ImplementationSpecific
# 示例:不同 Ingress 复用相同 CLB 监听器,各自使用不同域名# 说明:# - 两个 Ingress 位于不同命名空间(ns1 和 ns2)# - 复用相同的 CLB(通过 kubernetes.io/ingress.existLbId 指定)# - 复用相同的监听器端口(80 和 8080)# - 各自使用不同的域名进行路由# - ns1 的 Ingress 使用域名: app1.example.com# - ns2 的 Ingress 使用域名: app2.example.comapiVersion: v1kind: Namespacemetadata:name: ns1---apiVersion: v1kind: Namespacemetadata:name: ns2---# Ingress 1: 使用域名 app1.example.comapiVersion: networking.k8s.io/v1kind: Ingressmetadata:annotations:ingress.cloud.tencent.com/listen-ports: '[{"HTTP": 80}]'ingress.cloud.tencent.com/enable-group: 'true'kubernetes.io/ingress.existLbId: lb-xxxxxxxx # 这里需要填写你自己的lbidname: app1-ingressnamespace: ns1spec:rules:- host: app1.example.comhttp:paths:- backend:service:name: app1-serverport:number: 80path: /pathType: Prefix---# Ingress 2: 使用域名 app2.example.com(复用相同的 CLB 和监听器)apiVersion: networking.k8s.io/v1kind: Ingressmetadata:annotations:ingress.cloud.tencent.com/listen-ports: '[{"HTTP": 80}]'ingress.cloud.tencent.com/enable-group: 'true'kubernetes.io/ingress.existLbId: lb-xxxxxxxx # 这里需要填写你自己的lbid(与上面相同)name: app2-ingressnamespace: ns2spec:rules:- host: app2.example.comhttp:paths:- backend:service:name: app2-serverport:number: 80path: /pathType: Prefix---# ns1 的 ServiceapiVersion: v1kind: Servicemetadata:name: app1-servernamespace: ns1labels:app: app1-serverspec:ports:- name: httpport: 80targetPort: 80selector:app: app1-servertype: NodePort---# ns1 的 DeploymentapiVersion: apps/v1kind: Deploymentmetadata:name: app1-servernamespace: ns1spec:replicas: 1selector:matchLabels:app: app1-servertemplate:metadata:labels:app: app1-serverspec:containers:- image: ccr.ccs.tencentyun.com/paas/anyservername: anyserverenv:- name: POD_NAMEvalueFrom:fieldRef:apiVersion: v1fieldPath: metadata.name---# ns2 的 ServiceapiVersion: v1kind: Servicemetadata:name: app2-servernamespace: ns2labels:app: app2-serverspec:ports:- name: httpport: 80targetPort: 80selector:app: app2-servertype: NodePort---# ns2 的 DeploymentapiVersion: apps/v1kind: Deploymentmetadata:name: app2-servernamespace: ns2spec:replicas: 1selector:matchLabels:app: app2-servertemplate:metadata:labels:app: app2-serverspec:containers:- image: ccr.ccs.tencentyun.com/paas/anyservername: anyserverenv:- name: POD_NAMEvalueFrom:fieldRef:apiVersion: v1fieldPath: metadata.name
支持进度
注解 | 解释 | 是否支持(复用场景下) |
ingress.cloud.tencent.com/listen-ports | 自定义监听端口 | 支持 |
ingress.cloud.tencent.com/direct-access | 开启 CLB 直通 Pod | 支持 |
ingress.cloud.tencent.com/auto-rewrite | 使用自动重定向 | 支持 |
kubernetes.io/ingress.rule-mix | 开启混合(http/https)协议 | 支持 |
kubernetes.io/ingress.http-rules | http 协议 | 支持 |
kubernetes.io/ingress.https-rules | https 协议 | 支持 |
ingress.cloud.tencent.com/enable-grace-deletion | Pod 优雅删除 | 支持 |
ingress.cloud.tencent.com/lb-rs-weight | 自定义后端 RS 权重 | 支持 |
ingress.cloud.tencent.com/tke-service-config | 使用手动拓展配置 | 支持 |
ingress.cloud.tencent.com/pass-to-target | 默认放通 | 支持 |
ingress.cloud.tencent.com/tke-service-config-auto | 使用自动生成拓展配置 | 不支持 |
ingress.cloud.tencent.com/rewrite-support | 使用手动重定向 | 废弃 |
功能变更说明
部分注解在多个 Ingress 复用 CLB 场景下的使用方式和语义有所调整。
手动重定向
注解:
ingress.cloud.tencent.com/rewrite-support状态:在多个 Ingress 复用 CLB 场景下废弃。
说明:该注解已废弃,为 Ingress 变更手动重定向规则只需在
kubernetes.io/ingress.http-rules 和 kubernetes.io/ingress.https-rules 中配置,无需添加此注解。自动重定向
注解:
ingress.cloud.tencent.com/auto-rewrite改动:在多个 Ingress 复用 CLB 场景下调整注解删除的语义。
说明:在多个 Ingress 复用 CLB 的场景下,删除该注解与将其值设为
false 均表示关闭自动重定向。常见问题
存量使用已有 CLB 的 Ingress 迁移问题
暂不支持通过为存量的 Ingress 添加注解
ingress.cloud.tencent.com/enable-group: 'true' 以迁移到复用场景。规则/配置冲突问题
控制器正常调谐时,Ingress 注解示例如下:
ingress.cloud.tencent.com/status.conditions: '[{"type":"Ready","status":"True","lastTransitionTime":"2025-10-07T11:30:53Z","reason":"Success","message":""}]'
若复用同一 CLB 的 Ingress 出现调谐异常,错误信息将暴露于注解中,例如:
ingress.cloud.tencent.com/status.conditions: '[{"type":"Ready","status":"False","lastTransitionTime":"2025-10-07T11:35:10Z","reason":"ListenerError","message":"SyncClientError\\nErrorCode: E4403\\nDetails: Group: lb-fgim8ppi. The loadbalancerhas port conflict in the listeners 80_HTTP.\\nOriginError: ingress ns1/server2listener 80_HTTP domain example.com's path / conflict: already owned by ns1/server1\\n"}]'
场景支持问题
复用 CLB 的 Ingress 不支持与使用已有 CLB 的 Ingress(未指定
ingress.cloud.tencent.com/enable-group: 'true'注解) 共用同一 CLB,报错示例如下:ingress.cloud.tencent.com/status.conditions: '[{"type":"Ready","status":"False","lastTransitionTime":"2025-10-09T12:29:05Z","reason":"LoadbalancerError","message":"SyncClientError\\nErrorCode: E4406\\nDetails: Group: lb-fgim8ppi. Can not use lb:ns1/server1 used by another ingress/multiClusterIngress .\\nOriginError:group can't reuse clb with ingress which has existLbId, please process\\n"}]'
复用 CLB 的 Ingress 暂不支持与 Service 共用同一 CLB,报错示例如下:
ingress.cloud.tencent.com/status.conditions: '[{"type":"Ready","status":"False","lastTransitionTime":"2025-10-09T12:40:01Z","reason":"LoadbalancerError","message":"SyncClientError\\nErrorCode: E4407\\nDetails: Group: lb-fgim8ppi. Can not use lb:lb-fgim8ppi used by another service ns1/svc1.\\nOriginError: ingress managed by group not support reuse clb with service\\n"}]'