Route
Routes is an OpenShift concept and solution that allows you to expose Kubernetes Services at a public URL so that external clients can reach your applications running in the Kubernetes cluster.
In CSM Operator, you set up external cluster access using Openshift routes by adding a
route
type listener to your Kafka resource
(listener.type:route
).
Once configuration is done, CSM Operator deploys multiple routes as well as multiple ClusterIP type Kubernetes Services. This means that you will have the following:
- A route and a corresponding ClusterIP that serves as an external bootstrap. This is used by clients for the initial connection and to receive metadata (advertised listeners) from the Kafka cluster.
- A unique route and a CluserIP for each Kafka Broker. The routes and the corresponding ClusterIPs are used to access the brokers directly and to distinguish the traffic for different brokers.
Kafka clients connect to the bootstrap route, which routes the request through the bootstrap ClusterIP to one of the brokers. From this broker, the client receives metadata that contains the hostnames of the per-broker routes. The client uses these addresses to connect to the routes dedicated to the specific broker. Afterward, the route directs traffic through its corresponding ClusterIP to its corresponding broker.
CSM Operator uses the HAProxy router and sets up routes with passthrough termination. This results in the following:
- Traffic going through a route is always secured and uses TLS encryption.
- Encrypted traffic is sent to the ClusterIP Service without data being decrypted in the process.
- The port that the routes listen on is fixed and is always 443. This is because HAProxy uses port 443 by default for HTTPS requests.
CSM Operator collects the hostnames assigned to the routes and uses the addresses to configure the advertised listeners in the Kafka brokers. So brokers are automatically configured to advertise the right address and ports. As a result, once setup is complete, you can connect your clients running outside of the Kubernetes network by directing them to the bootstrap route. Kubernetes and OpenShift handle everything else and ensure that client requests are routed to the correct brokers.
Configuring route listeners
Complete the following steps to set up and configure a route type listener in CSM Operator. The following steps also include an example on how to connect a Kafka console client to the cluster.
These steps demonstrate basic listener configuration with typical customizations. In
addition to the configuration shown here, you can further customize your listener
and specify a client authentication mechanism with the
authentication
property and add various additional
configurations using the configuration
property. For a
comprehensive list of available properties, see GenericKafkaListener
schema reference in the Strimzi API reference.