Skip to content

Commit 2cf6886

Browse files
weltekialexellis
authored andcommitted
Add Helm chart for the RabbitMQ connector
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
1 parent 781d785 commit 2cf6886

File tree

7 files changed

+533
-1
lines changed

7 files changed

+533
-1
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ verify-charts:
8686
arkade chart verify --verbose=$(VERBOSE) -f ./chart/postgres-connector/values.yaml && \
8787
arkade chart verify --verbose=$(VERBOSE) -f ./chart/queue-worker/values.yaml && \
8888
arkade chart verify --verbose=$(VERBOSE) -f ./chart/sns-connector/values.yaml && \
89-
arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/federated-gateway/values.yaml
89+
arkade chart verify --verbose=$(VERBOSE) -f ./chart/rabbitmq-connector/values.yaml && \
90+
arkade chart verify --verbose=$(VERBOSE) -f ./chart/federated-gateway/values.yaml
9091

9192
verify-chart:
9293
@echo Verifying helm chart images in remote registries && \
@@ -109,6 +110,7 @@ upgrade-charts:
109110
arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/postgres-connector/values.yaml && \
110111
arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/queue-worker/values.yaml && \
111112
arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/sns-connector/values.yaml && \
113+
arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/rabbitmq-connector/values.yaml && \
112114
arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/federated-gateway/values.yaml
113115

114116
bump-charts:
@@ -122,6 +124,7 @@ bump-charts:
122124
arkade chart bump --file ./chart/postgres-connector/Chart.yaml -w && \
123125
arkade chart bump --file ./chart/queue-worker/Chart.yaml -w && \
124126
arkade chart bump --file ./chart/sns-connector/Chart.yaml -w && \
127+
arkade chart bump --file ./chart/rabbitmq-connector/Chart.yaml -w && \
125128
arkade chart bump --file ./chart/federated-gateway/Chart.yaml -w
126129

127130
charts-only:
@@ -136,6 +139,7 @@ charts-only:
136139
helm package postgres-connector/ && \
137140
helm package queue-worker/ && \
138141
helm package sns-connector/ && \
142+
helm package rabbitmq-connector/ && \
139143
helm package federated-gateway/
140144
mv chart/*.tgz docs/
141145
helm repo index docs --url https://openfaas.github.io/faas-netes/ --merge ./docs/index.yaml

chart/rabbitmq-connector/.helmignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
.vscode/

chart/rabbitmq-connector/Chart.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
description: Invoke OpenFaaS functions from RabbitMQ messages.
3+
name: rabbitmq-connector
4+
version: 0.1.0
5+
sources:
6+
- https://github.com/openfaas/faas-netes
7+
home: https://www.openfaas.com
8+
icon: https://raw.githubusercontent.com/openfaas/media/master/OpenFaaS_logo_stacked_opaque.png
9+
keywords:
10+
- openfaas
11+
- faas
12+
- serverless
13+
- rabbitmq
14+
- events
15+
maintainers:
16+
- name: alexellis
17+
18+
- name: welteki
19+

chart/rabbitmq-connector/README.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "connector.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "connector.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "connector.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+

0 commit comments

Comments
 (0)