// Module included in the following assemblies:
//
// * configuring_ingress_cluster_traffic/configuring-ingress-cluster-traffic-ingress-controller.adoc
// * ingress-operator.adoc

:_mod-docs-content-type: PROCEDURE
[id="nw-ingress-sharding-namespace-labels_{context}"]
= Configuring Ingress Controller sharding by using namespace labels

[role="_abstract"]
You can use namespace labels to configure Ingress Controller sharding so that the Ingress Controller serves any route in any namespace that is selected by the namespace selector.

.Ingress sharding by using namespace labels
image::nw-sharding-namespace-labels.png[A diagram showing multiple Ingress Controllers with different namespace selectors serving routes that belong to the namespace containing a label that matches a given namespace selector]

Ingress Controller sharding is useful when balancing incoming traffic load among
a set of Ingress Controllers and when isolating traffic to a specific Ingress
Controller. For example, company A goes to one Ingress Controller and company B
to another.

.Procedure

. Edit the `router-internal.yaml` file:
+
[source,terminal]
----
$ cat router-internal.yaml
----
+
.Example output
[source,yaml]
----
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: ""
  namespaceSelector:
    matchLabels:
      type: sharded
----
* `<apps-sharded.basedomain.example.net>`: Specify a domain to be used by the Ingress Controller. This domain must be different from the default Ingress Controller domain.

. Apply the Ingress Controller `router-internal.yaml` file:
+
[source,terminal]
----
$ oc apply -f router-internal.yaml
----
+
The Ingress Controller selects routes in any namespace that is selected by the
namespace selector that have the label `type: sharded`.

. Create a new route by using the domain configured in the `router-internal.yaml`:
+
[source,terminal]
----
$ oc expose svc <service-name> --hostname <route-name>.apps-sharded.basedomain.example.net
----
