Search code examples
apache-kafkaopenshiftknativestrimziknative-eventing

How do I configure multi-tenant Kafka-backed Knative channels in an Openshift?


Goal:

We want to support multiple environments in the same Openshift. We use the service mesh control plan and namespaces defined in the member rolls, as the boundaries for each environment. Each environment also has its own Kafka cluster, installed using the Openshift AMQP operator.

We’ve also also installed the Openshift serverless operator and deployed a Knative Eventing control plane (along with a Knative Serving control plane). We’ve found that only one knative eventing control plane can be installed in each cluster, as it is restricted to a certain namespace name, and you can only have one control plane in a namespace For each environment there is a handful of Knative channels (we use the channel/subscription model, but we can use brokers and trigger as wells, if that solves the problem) which are backed by the kafka cluster of that environment.

We use the subscriptions to push events to Knative services.

Issue:

It seems that the kafka bootstrap server domains are configured in the control plane (KnativeKafka resource specifically), for which we can only have one of per openshift cluster. This means that we can ensure that data/events in one environments ends up in the kafka cluster in that same environment.

How would one go about creating two Knative channels in the same cluster, but configured in such a way, so that the events of each are guaranteed to end up in different kafka clusters, all within the same openshift cluster?

The details:

Openshift v4.14.12_1552

Red Hat AMQP Streams v2.6.0-1

Which uses:

  • Kafka v3.6.0
  • Strimzi v0.38

Openshift Serverless v1.31.1

Which uses:

  • Knative Serving v1.10
  • Knative Eventing v1.10

Solution

  • Solving your issue is only possible when using the Broker and Trigger model as currently Kafka channels are not configurable per-resource.

    Each Broker can be configured to use a separate configuration (referenced in a Brokers .spec.config). In this config you can config your bootstrap servers then (see configure a kafka broker).

    So you could use something like the following, to configure your Broker to use a "dedicated" broker config:

    apiVersion: eventing.knative.dev/v1
    kind: Broker
    metadata:
      annotations:
        eventing.knative.dev/broker.class: Kafka
      name: my-broker
    spec:
      config:
        apiVersion: v1
        kind: ConfigMap
        name: my-broker-config
        namespace: my-ns
    

    and then your Broker configmap (which can be referenced by multiple Brokers)

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: my-broker-config
      namespace: my-ns
    data:
      bootstrap.servers: "my-cluster-kafka-bootstrap-123.kafka:9092"
      default.topic.partitions: "10"
      default.topic.replication.factor: "3"