Self-hosted Kafka
Integrate self-hosted Kafka with Seldon Core 2.
You can run Kafka in the same Kubernetes cluster that hosts the Seldon Core 2. Seldon recommends using the Strimzi operator for Kafka installation and maintenance. For more details about configuring Kafka with Seldon Core 2 see the Configuration section.
Note: These instructions help you quickly set up a Kafka cluster. For production grade installation consult Strimzi documentation or use one of managed solutions.
Integrating self-hosted Kafka with Seldon Core 2 includes these steps:
Installing Kafka in a Kubernetes cluster
Strimzi provides a Kubernetes Operator to deploy and manage Kafka clusters. First, we need to install the Strimzi Operator in your Kubernetes cluster.
Create a namespace where you want to install Kafka. For example the namespace
seldon-mesh
:Install Strimzi.
Install Strimzi Operator.
This deploys the
Strimzi Operator
in theseldon-mesh
namespace. After the Strimzi Operator is running, you can create a Kafka cluster by applying a Kafka custom resource definition.Create a YAML file to specify the initial configuration.
Note: This configuration sets up a Kafka cluster with version 3.9.0. Ensure that you review the the supported versions of Kafka and update the version in the
kafka.yaml
file as needed. For more configuration examples, see this strimzi-kafka-operator.Use your preferred text editor to create and save the file as
kafka.yaml
with the following content:
Apply the Kafka cluster configuration.
Create a YAML file named
kafka-nodepool.yaml
to create a nodepool for the kafka cluster.
Apply the Kafka node pool configuration.
Check the status of the Kafka Pods to ensure they are running properly:
Note: It might take a couple of minutes for all the Pods to be ready.
To check the status of the Pods in real time use this command: kubectl get pods -w -n seldon-mesh
.
You should see multiple Pods for Kafka, and Strimzi operators running.
Troubleshooting
Error
The Pod that begins with the name seldon-dataflow-engine
does not show the status as Running
.
One of the possible reasons could be that the DNS resolution for the service failed.
Solution
Check the logs of the Pod
<seldon-dataflow-engine>
:In the output check if a message reads:
Verify the
name
in themetadata
for thekafka.yaml
andkafka-nodepool.yaml
. It should readseldon
.Check the name of the Kafka services in the namespace:
Restart the Pod:
Configuring Seldon Core 2
When the SeldonRuntime
is installed in a namespace a ConfigMap is created with the
settings for Kafka configuration. Update the ConfigMap
only if you need to customize the configurations.
Verify that the ConfigMap resource named
seldon-kafka
that is created in the namespaceseldon-mesh
:You should the ConfigMaps for Kafka, Zookeeper, Strimzi operators, and others.
View the configuration of the the ConfigMap named
seldon-kafka
.You should see an output simialr to this:
After you integrated Seldon Core 2 with Kafka, you need to Install an Ingress Controller that adds an abstraction layer for traffic routing by receiving traffic from outside the Kubernetes platform and load balancing it to Pods running within the Kubernetes cluster.
Customizing the settings (optional)
To customize the settings you can add and modify the Kafka configuration using Helm, for example to add compression for producers.
Create a YAML file to specify the compression configuration for Seldon Core 2 runtime. For example, create the
values-runtime-kafka-compression.yaml
file. Use your preferred text editor to create and save the file with the following content:
Change to the directory that contains the
values-runtime-kafka-compression.yaml
file and then install Seldon Core 2 runtime in the namespaceseldon-mesh
.
Configuring topic and consumer isolation (optional)
If you are using a shared Kafka cluster with other applications, it is advisable to isolate topic names and consumer group IDs from other cluster users to prevent naming conflicts. This can be achieved by configuring the following two settings:
topicPrefix
: set a prefix for all topicsconsumerGroupIdPrefix
: set a prefix for all consumer groups
Here’s an example of how to configure topic name and consumer group ID isolation during a Helm installation for an application named myorg
:
Next Steps
After you installed Seldon Core 2, and Kafka using Helm, you need to complete Installing a Service mesh.
Last updated
Was this helpful?