|
| 1 | +# OpenFaaS Pro RabbitMQ Connector |
| 2 | + |
| 3 | +The RabbitMQ connector can be used to invoke OpenFaaS functions from messages on a RabbitMQ queue. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Purchase a license |
| 8 | + |
| 9 | + You will need an OpenFaaS License |
| 10 | + |
| 11 | + Contact us to find out more [openfaas.com/pricing](https://www.openfaas.com/pricing) |
| 12 | + |
| 13 | +- Install OpenFaaS |
| 14 | + |
| 15 | + You must have a working OpenFaaS installed. |
| 16 | + |
| 17 | +## Configure secrets |
| 18 | + |
| 19 | +- Create the required secret with your OpenFaaS Pro license code: |
| 20 | + |
| 21 | +```bash |
| 22 | +$ kubectl create secret generic \ |
| 23 | + -n openfaas \ |
| 24 | + openfaas-license \ |
| 25 | + --from-file license=$HOME/.openfaas/LICENSE |
| 26 | +``` |
| 27 | + |
| 28 | +## Configure values.yaml |
| 29 | + |
| 30 | +```yaml |
| 31 | +rabbitmqURL: "amqp://rabbitmq.rabbitmq.svc.cluster.local:5672" |
| 32 | + |
| 33 | +queues: |
| 34 | + - name: queue1 |
| 35 | + durable: true |
| 36 | +``` |
| 37 | +
|
| 38 | +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. |
| 39 | + |
| 40 | +Queue configuration: |
| 41 | + |
| 42 | +- `name` - The name of the queue. (Required) |
| 43 | +- `durable` - Specifies whether the queue should survive broker restarts. |
| 44 | +- `nowait` - Whether to wait for confirmation from the server when declaring the queue. |
| 45 | +- `autodelete` - Whether the queue should be deleted automatically when no consumers are connected. |
| 46 | +- `exclusive` - Specifies whether the queue should be exclusive to the connection that created it. |
| 47 | + |
| 48 | +By default the connector does not use any form of authentication for the RabbitMQ connection. |
| 49 | + |
| 50 | +Create Kubernetes secrets with username and password to connect to RabbitMQ if required. |
| 51 | + |
| 52 | +```sh |
| 53 | +kubectl create secret generic \ |
| 54 | + rabbitmq-username \ |
| 55 | + -n openfaas \ |
| 56 | + --from-file username=./rabbitmq-username.txt |
| 57 | +
|
| 58 | +kubectl create secret generic \ |
| 59 | + rabbitmq-password \ |
| 60 | + -n openfaas \ |
| 61 | + --from-file password=./rabbitmq-password.txt |
| 62 | +``` |
| 63 | + |
| 64 | +To enable username and password authentication add to following parameters with the Kubernetes secret name for the username and password to the `values.yaml`. |
| 65 | + |
| 66 | +```yaml |
| 67 | +rabbitmqUsernameSecret: rabbitmq-username |
| 68 | +rabbitmqPasswordSecret: rabbitmq-password |
| 69 | +``` |
| 70 | + |
| 71 | +If your RabbitMQ requires a TLS connection make sure to use `amqps://` as the scheme in the url. |
| 72 | + |
| 73 | +Optionally you can configure a custom CA cert for the connector: |
| 74 | + |
| 75 | +```sh |
| 76 | +kubectl create secret generic \ |
| 77 | + rabbitmq-ca \ |
| 78 | + -n openfaas \ |
| 79 | + --from-file ca-cert=./ca-cert.pem |
| 80 | +``` |
| 81 | + |
| 82 | +`values.yaml`: |
| 83 | + |
| 84 | +```yaml |
| 85 | +caSecret: "rabbitmq-ca" |
| 86 | +``` |
| 87 | + |
| 88 | +## Install the chart |
| 89 | + |
| 90 | +- Add the OpenFaaS chart repo and deploy the `rabbitmq-connector` chart. We recommend installing it in the same namespace as the rest of OpenFaaS |
| 91 | + |
| 92 | +```sh |
| 93 | +$ helm repo add openfaas https://openfaas.github.io/faas-netes/ |
| 94 | +$ helm repo update && \ |
| 95 | + helm upgrade rabbitmq-connector openfaas/rabbitmq-connector \ |
| 96 | + --install \ |
| 97 | + --namespace openfaas \ |
| 98 | + -f values.yaml |
| 99 | +``` |
| 100 | + |
| 101 | +> The above command will also update your helm repo to pull in any new releases. |
| 102 | + |
| 103 | +## Configuration |
| 104 | + |
| 105 | +Additional rabbitmq-connector options in `values.yaml`. |
| 106 | + |
| 107 | +| Parameter | Description | Default | |
| 108 | +| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | |
| 109 | +| `topics` | A single topic or list of comma separated topics to consume. | `faas-request` | |
| 110 | +| `replicas` | The 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` | |
| 111 | +| `rabbitmqURL` | URL used for connecting to a RabbitMQ node. | `amqp://rabbitmq:5672` | |
| 112 | +| `queues` | List of queues the connector should subscribe to. | `[]` | |
| 113 | +| `asyncInvocation` | For long running or slow functions, offload to asychronous function invocations and carry on processing the stream | `false` | |
| 114 | +| `upstreamTimeout` | Maximum timeout for upstream function call, must be a Go formatted duration string. | `2m` | |
| 115 | +| `rebuildInterval` | Interval for rebuilding function to topic map, must be a Go formatted duration string. | `30s` | |
| 116 | +| `gatewayURL` | The URL for the OpenFaaS gateway. | `http://gateway.openfaas:8080` | |
| 117 | +| `printResponse` | Output the response of calling a function in the logs. | `true` | |
| 118 | +| `printResponseBody` | Output to the logs the response body when calling a function. | `false` | |
| 119 | +| `printRequestBody` | Output to the logs the request body when calling a function. | `false` | |
| 120 | +| `fullnameOverride` | Override the name value used for the Connector Deployment object. | `""` | |
| 121 | +| `rabbitmqPasswordSecret` | Name of the RabbitMQ password secret | `""` | |
| 122 | +| `rabbitmqUsernameSecret` | Name of the RabbitMQ username secret | `""` | |
| 123 | +| `caSecret` | Name secret for TLS CA - leave empty to disable | `""` | |
| 124 | +| `certSecret` | Name secret for TLS client certificate cert - leave empty to disable | `""` | |
| 125 | +| `keySecret` | Name secret for TLS client certificate private key - leave empty to disable | `""` | |
| 126 | +| `contentType` | Set a HTTP Content Type during function invocation. | `text/plain` | |
| 127 | +| `logs.debug` | Print debug logs | `false` | |
| 128 | +| `logs.format` | The log encoding format. Supported values: `json` or `console` | `console` | |
| 129 | + |
| 130 | +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. See `values.yaml` for the default configuration. |
| 131 | + |
| 132 | +## Install a development version of the chart |
| 133 | + |
| 134 | +When developing on the chart locally, just specify the path to the chart where you've cloned it: |
| 135 | + |
| 136 | +```sh |
| 137 | +$ helm upgrade rabbitmq-connector ./chart/rabbitmq-connector \ |
| 138 | + --install \ |
| 139 | + --namespace openfaas \ |
| 140 | + -f values.yaml |
| 141 | +``` |
| 142 | + |
| 143 | +## Removing the rabbitmq-connector |
| 144 | + |
| 145 | +All control plane components can be cleaned up with helm: |
| 146 | + |
| 147 | +```sh |
| 148 | +$ helm uninstall -n openfaas rabbitmq-connector |
| 149 | +``` |
0 commit comments