kafka-connector

by Helm

Helm chartv0.7.17

Connect OpenFaaS functions to Kafka topics

About this chart

OpenFaaS Pro Kafka Connector

The Kafka connector brings Kafka to OpenFaaS by invoking functions based on Kafka topic annotations.

See also: Docs & tutorials for the Kafka connector

Prerequisites

  • Obtain an license for OpenFaaS

    You will need an OpenFaaS license, find out more

  • Install OpenFaaS

    You must have a working OpenFaaS installation.

  • Option 1 - hosted Kafka

    Aiven and Confluent Cloud have both been tested with the Kafka Connector.

    Other hosted Kafka offerings such as Kafka like Redpanda should also work.

  • Option 2 - Self-hosted Kafka

    For development and testing, you can install Apache Kafka using Confluent's chart. Find out additional options here: available here

  • Option 3 - Use an existing Kafka deployment

    If you already have Kafka deployed, you'll all the usual details such as whether TLS is enabled along with any required certs, what kind of authentication is being used, what the topic names are, and the partition size for each.

Install the Chart

  • Create the required secret with your OpenFaaS Pro license code:
$ kubectl create secret generic \
    -n openfaas \
    openfaas-license \
    --from-file license=$HOME/.openfaas/LICENSE
  • Add the OpenFaaS chart repo and deploy the kafka-connector Pro chart. We recommend installing it in the same namespace as the rest of OpenFaaS
$ helm repo add openfaas https://openfaas.github.io/faas-netes/

Prepare a custom values.yaml with:

  • brokerHosts - comma separted list of host:port
  • topics - the topics to subscribe to
  • replicas - this should match the partition size, so if the size is 3, set this to 3

Then you will need to read up on the encryption and authentication options and update the settings accordingly.

$ helm repo update && \
  helm upgrade kafka-connector openfaas/kafka-connector \
    --install \
    --namespace openfaas \
    -f ./custom-values.yaml

The above command will also update your helm repo to pull in any new releases.

Encryption options

  1. TLS off (default)
  2. TLS on

Authentication options

  1. TLS with SASL using CA from the default trust store
  2. TLS with SASL using a custom CA
  3. TLS with client certificates

Configuration

Additional kafka-connector options in values.yaml.

ParameterDescriptionDefault
topicsA single topic or list of comma separated topics to consume.faas-request
replicasThe number of replicas of this connector, should be set to the size of the partition for the given topic, or a higher lower value.1
brokerHostsHost and port for the Kafka bootstrap server, multiple servers can be specified as a comma-separated list.kafka:9092
asyncInvocationFor long running or slow functions, offload to asychronous function invocations and carry on processing the streamfalse
upstreamTimeoutMaximum timeout for upstream function call, must be a Go formatted duration string.2m
rebuildIntervalInterval for rebuilding function to topic map, must be a Go formatted duration string.30s
gatewayURLThe URL for the API gateway.http://gateway.openfaas:8080
printResponseOutput the response of calling a function in the logs.true
printResponseBodyOutput to the logs the response body when calling a function.false
printRequestBodyOutput to the logs the request body when calling a function.false
fullnameOverrideOverride the name value used for the Connector Deployment object.``
tlsConnect to the broker server(s) using TLS encryptiontrue
saslEnable auth with a SASL username/passwordfalse
brokerPasswordSecretName of secret for SASL passwordkafka-broker-password
brokerUsernameSecretName of secret for SASL usernamekafka-broker-username
caSecretName secret for TLS CA - leave empty to disablekafka-broker-ca
certSecretName secret for TLS client certificate cert - leave empty to disablekafka-broker-cert
keySecretName secret for TLS client certificate private key - leave empty to disablekafka-broker-key
contentTypeSet a HTTP Content Type during function invocation.""
groupSet the Kafka consumer group name.""
maxBytesSet the maximum size of messages from the Kafka broker.1024*1024
sessionLoggingEnable detailed logging from the consumer group."false"
initialOffsetEither newest or oldest."oldest"
logs.debugPrint debug logsfalse
logs.formatThe log encoding format. Supported values: json or consoleconsole

Specify each parameter using the --set key=value[,key=value] argument to helm install. See values.yaml for the default configuration.

Install a development version of the chart

When developing on the chart locally, just specify the path to the chart where you've cloned it:

$ helm upgrade kafka-connector ./chart/kafka-connector \
    --install \
    --namespace openfaas \
    -f values.yaml

Removing the kafka-connector

All control plane components can be cleaned up with helm:

$ helm uninstall -n openfaas kafka-connector

Deploy kafka-connector with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kafka-connector on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartkafka-connector is pinned at v0.7.17 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply