rabbitmq-connector

by Helm

Helm chartv0.0.4

Invoke OpenFaaS functions from RabbitMQ messages.

About this chart

OpenFaaS Pro RabbitMQ Connector

The RabbitMQ connector can be used to invoke OpenFaaS functions from messages on a RabbitMQ queue.

Prerequisites

  • Purchase a license

    You will need an OpenFaaS License

    Contact us to find out more openfaas.com/pricing

  • Install OpenFaaS

    You must have a working OpenFaaS installed.

Configure secrets

  • Create the required secret with your OpenFaaS Pro license code:
$ kubectl create secret generic \
    -n openfaas \
    openfaas-license \
    --from-file license=$HOME/.openfaas/LICENSE

Configure values.yaml

rabbitmqURL: "amqp://rabbitmq.rabbitmq.svc.cluster.local:5672"

queues:
  - name: queue1
    durable: true

Use the queues parameter to configure a list of queues to which the connector should subscribe. When a message is received on a queue, the connector will attempt to invoke any function that has the queue name listed in its topic annotation.

Queue configuration:

  • name - The name of the queue. (Required)
  • durable - Specifies whether the queue should survive broker restarts.
  • nowait - Whether to wait for confirmation from the server when declaring the queue.
  • autodelete - Whether the queue should be deleted automatically when no consumers are connected.
  • exclusive - Specifies whether the queue should be exclusive to the connection that created it.

By default the connector does not use any form of authentication for the RabbitMQ connection.

Create Kubernetes secrets with username and password to connect to RabbitMQ if required.

kubectl create secret generic \
  rabbitmq-username \
  -n openfaas \
  --from-file username=./rabbitmq-username.txt

kubectl create secret generic \
  rabbitmq-password \
  -n openfaas \
  --from-file password=./rabbitmq-password.txt

To enable username and password authentication add to following parameters with the Kubernetes secret name for the username and password to the values.yaml.

rabbitmqUsernameSecret: rabbitmq-username
rabbitmqPasswordSecret: rabbitmq-password

If your RabbitMQ requires a TLS connection make sure to use amqps:// as the scheme in the url.

Optionally you can configure a custom CA cert for the connector:

kubectl create secret generic \
  rabbitmq-ca \
  -n openfaas \
  --from-file ca-cert=./ca-cert.pem

values.yaml:

caSecret: "rabbitmq-ca"

Install the chart

  • Add the OpenFaaS chart repo and deploy the rabbitmq-connector chart. We recommend installing it in the same namespace as the rest of OpenFaaS
$ helm repo add openfaas https://openfaas.github.io/faas-netes/
$ helm repo update && \
  helm upgrade rabbitmq-connector openfaas/rabbitmq-connector \
    --install \
    --namespace openfaas \
    -f values.yaml

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

Configuration

Additional rabbitmq-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
rabbitmqURLURL used for connecting to a RabbitMQ node.amqp://rabbitmq:5672
queuesList of queues the connector should subscribe to.[]
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 OpenFaaS 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.""
rabbitmqPasswordSecretName of the RabbitMQ password secret""
rabbitmqUsernameSecretName of the RabbitMQ username secret""
caSecretName secret for TLS CA - leave empty to disable""
certSecretName secret for TLS client certificate cert - leave empty to disable""
keySecretName secret for TLS client certificate private key - leave empty to disable""
contentTypeSet a HTTP Content Type during function invocation.text/plain
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 rabbitmq-connector ./chart/rabbitmq-connector \
    --install \
    --namespace openfaas \
    -f values.yaml

Removing the rabbitmq-connector

All control plane components can be cleaned up with helm:

$ helm uninstall -n openfaas rabbitmq-connector

Deploy rabbitmq-connector with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has rabbitmq-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 chartrabbitmq-connector is pinned at v0.0.4 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