6.8.5. Ingress Controller 分片

Ingress Controller 或路由器是网络流量进入集群的主要机制,因此对它们的需求可能非常大。作为集群管理员,您可以对路由进行分片,以达到以下目的:

  • 在 Ingress Controller 或路由器与一些路由之间实现平衡,由此加快对变更的响应。
  • 分配特定的路由,使其具有不同于其它路由的可靠性保证。
  • 允许特定的 Ingress Controller 定义不同的策略。
  • 只允许特定的路由使用其他功能。
  • 在不同的地址上公开不同的路由,例如使内部和外部用户能够看到不同的路由。

Ingress Controller 可以使用路由标签或命名空间标签作为分片方法。

6.8.5.1. 通过路由标签(label)配置 Ingress Controller 分片

使用路由标签进行 Ingress Controller 分片,意味着 Ingress Controller 提供由路由选择器选择的任意命名空间中的所有路由。

在一组 Ingress Controller 之间平衡传入的流量负载时,以及在将流量隔离到特定 Ingress Controller 时,Ingress Controller 分片会很有用处。例如,A 公司的流量使用一个 Ingress Controller,B 公司的流量则使用另外一个 Ingress Controller。

流程

  1. 编辑 router-internal.yaml 文件:

    # cat router-internal.yaml
    apiVersion: v1
    items:
    - apiVersion: operator.openshift.io/v1
      kind: IngressController
      metadata:
        name: sharded
        namespace: openshift-ingress-operator
      spec:
        domain: <apps-sharded.basedomain.example.net>
        nodePlacement:
          nodeSelector:
            matchLabels:
              node-role.kubernetes.io/worker: ""
        routeSelector:
          matchLabels:
            type: sharded
      status: {}
    kind: List
    metadata:
      resourceVersion: ""
      selfLink: ""
  2. 应用 Ingress Controller router-internal.yaml 文件:

    # oc apply -f router-internal.yaml

    Ingress Controller 选择具有 type: sharded 标签的任意命名空间中的路由。