An ansible playbook for installing Kafka and Kubeless on a running Openshift instance.
Kubeless is a Kubernetes-native serverless solution which uses Apache Kafka for messaging under the hood. By default Kubeless runs a Kafka instance for you, but a custom cluster can be used instead (for example, if one already exists in the Kubernetes/Openshift cluster, or if a higher level of configuration is needed). This playbook handles the setup necessary to do this, and uses Strimzi for the Kafka cluster. Strimzi provides a way to run an Apache Kafka cluster on OpenShift and Kubernetes in various deployment configurations.
To start the playbook, make sure you have ansible installed, and run the following command:
ansible-playbook site.yml
Can be edited in group_vars/all.
kubeless_namespace
: The name of the Kubeless namespacekafka_namespace
: The name of the Strimzi/Kafka namespacekafka_cluster_name
: The name of the Strimzi/Kafka cluster
When setting up the Kubeless instance, a trigger controller is also created. This allows functions to be triggered whenever messages are published to given (trigger) topics in Kafka. To do this,
- Create a kubeless kafka trigger. This needs to associate a function with a topic that, when published to, will cause it to be invoked. For example, a
hello_world
function could be invoked whenever a producer publishes a message to thehello
topic - Produce a message to that topic (for testing I usually use these Go producers/consumers)
- That's it! The function should be invoked.
A guided example can be found in this blog post.