Skip to content

Commit 574e186

Browse files
author
github-actions
committed
Merge branch 'release/v0.4.0' into main
2 parents 34c8935 + 7932cb9 commit 574e186

File tree

9 files changed

+334
-18
lines changed

9 files changed

+334
-18
lines changed

deploy-versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"text":"latest","key":"latest","tag":"v0.3.3"}]
1+
[{"text":"latest","key":"latest","tag":"v0.4.0"}]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zilla-docs",
3-
"version": "0.3.3",
3+
"version": "0.4.0",
44
"description": "The official documentation for the aklivity/zilla open-source project",
55
"keywords": [],
66
"author": "aklivity.io",

src/.vuepress/sidebar/en.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,18 @@ export const enSidebar = sidebar({
204204
text: "Overview",
205205
link: "concepts/kafka-proxies/mqtt-proxy.md",
206206
},
207+
{
208+
text: "Create a Simple MQTT Broker",
209+
link: "tutorials/mqtt/mqtt-intro.md",
210+
},
211+
{
212+
text: "Running an MQTT Kafka broker",
213+
link: "how-tos/mqtt/mqtt.kafka.broker.md",
214+
},
207215
{
208216
text: "Run the Taxi Demo",
209217
link: "https://github.com/aklivity/zilla-demos/tree/main/taxi",
210218
},
211-
{
212-
text: "Create a Simple MQTT Broker",
213-
link: "tutorials/mqtt/mqtt-intro.md",
214-
}
215219
],
216220
},
217221
{

src/concepts/config-intro.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,58 @@ See each of the specific `guard` types linked below for more detailed examples.
9898

9999
## Vaults
100100

101-
Each configured `vault` represents a container for digital keys and certificates based on a specific implementation `type`.
101+
Each configured [vault](../reference/config/vaults/) represents a container for digital keys and certificates based on a specific implementation `type`.
102102

103-
Vaults can be used by specific protocol bindings, such as `tls`, to negotiate shared encryption keys.
103+
### Server Encryption, TLS & SSL
104104

105-
See each of the specific `vault` types linked below for more detailed examples.
105+
Vaults can be used by specific protocol bindings, such as [tls](../reference/config/bindings/binding-tls.md), to negotiate shared encryption keys. It is easy to add the necessary routing logic and encryption keys.
106+
107+
Using a [filesystem](../reference/config/vaults/vault-filesystem.md) vault, you can see how a pkcs12 certificate on the host is configured to be stored securely by the Zilla runtime. This keystore can then be used by the [tls](../reference/config/bindings/binding-tls.md) binding to decrypt incoming traffic.
108+
109+
```yaml{6}
110+
vaults:
111+
your_servers:
112+
type: filesystem
113+
options:
114+
keys:
115+
store: your_servers.p12
116+
type: pkcs12
117+
password: ${{env.KEYSTORE_PASSWORD}}
118+
```
119+
120+
The [tcp](../reference/config/bindings/binding-tcp.md) binding can be configured for both encrypted and unencrypted traffic on separate ports. Take the SSL example with ports `80` and `443`. The [tls](../reference/config/bindings/binding-tls.md) binding will use the `keys` as the certificate aliases and the Server Name Indication (`sni`) as the SSL server names. These will likely be the same. Since this example is over [http](../reference/config/bindings/binding-http.md) the Application-Layer Protocol Negotiation (ALPN) will need to handle both HTTP/1.1 and HTTP/2, but the [tls](../reference/config/bindings/binding-tls.md) binding can be configured for any of the [alpn](../reference/config/bindings/binding-tls.md#options-alpn) protocols supported by Zilla.
121+
122+
```yaml{20,29}
123+
bindings:
124+
tcp_server:
125+
type: tcp
126+
kind: server
127+
options:
128+
host: 0.0.0.0
129+
port:
130+
- 80
131+
- 443
132+
routes:
133+
- when:
134+
- port: 80
135+
exit: http_server
136+
- when:
137+
- port: 443
138+
exit: tls_server
139+
tls_server:
140+
type: tls
141+
kind: server
142+
vault: your_servers
143+
options:
144+
keys:
145+
- your_server.com
146+
sni:
147+
- your_server.com
148+
alpn:
149+
- http/1.1
150+
- h2
151+
exit: http_server
152+
```
106153

107154
## Telemetry
108155

src/concepts/kafka-proxies/mqtt-proxy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ bindings:
111111

112112
## Try it out
113113

114-
Go check out the [MQTT Kafka Reflect example](https://github.com/aklivity/zilla-examples/tree/main/mqtt.kafka.broker) or the [JWT Auth example](https://github.com/aklivity/zilla-examples/tree/main/mqtt.kafka.broker.jwt) example for a full implementation of an MQTT proxy.
114+
Go check out the [Running an MQTT Kafka broker](../../how-tos/mqtt/mqtt.kafka.broker.md) or the [JWT Auth example](https://github.com/aklivity/zilla-examples/tree/main/mqtt.kafka.broker.jwt) example for a full implementation of an MQTT proxy.

src/how-tos/install.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ The output should display the zilla config and `started` to know zilla is ready
1212

1313
```output:no-line-numbers
1414
// default Zilla config
15-
{
16-
"name": "default"
17-
}
15+
name: default
1816
1917
// Zilla status
2018
started
@@ -45,7 +43,7 @@ Go to the [Zilla artifacthub](https://artifacthub.io/) page to find out more on
4543
### TL;DR
4644

4745
```bash:no-line-numbers
48-
helm install zilla . --namespace zilla --create-namespace --wait \
46+
helm install zilla oci://ghcr.io/aklivity/charts/zilla --namespace zilla --create-namespace --wait \
4947
--values values.yaml \
5048
--set-file zilla\\.yaml=zilla.yaml
5149
```

src/how-tos/mqtt/mqtt.kafka.broker.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
---
2+
description: In this guide, you create Kafka topics and use Zilla to mediate MQTT broker messages onto those topics.
3+
---
4+
5+
# Running an MQTT Kafka broker
6+
7+
In this guide, you create Kafka topics and use Zilla to mediate MQTT broker messages onto those topics.
8+
9+
Specifically, you will:
10+
11+
[Verify prerequisites](#prerequisites) to run this guide.
12+
[Install and run](#tl-dr) Zilla with Kafka or use your own.
13+
[Create topics](#check-the-kafka-topics) for the MQTT broker messages.
14+
[Watch Kafka](#listen-for-messages) for new messages on the topics.
15+
[Pub & Sub](#send-a-greeting) with an MQTT client.
16+
17+
## Tl;Dr
18+
19+
Download and run the Zilla [zilla-examples/mqtt.kafka.broker](https://github.com/aklivity/zilla-examples/tree/main/mqtt.kafka.broker) example using this install script. It will start Zilla and everything you need for this guide.
20+
21+
```bash:no-line-numbers
22+
wget -qO- https://raw.githubusercontent.com/aklivity/zilla-examples/main/startup.sh | sh -s -- mqtt.kafka.broker
23+
```
24+
25+
::: note
26+
Alternatively, download [mqtt.kafka.broker](https://github.com/aklivity/zilla-examples/releases/latest/download/mqtt.kafka.broker.tar.gz) or the [startup.sh](https://github.com/aklivity/zilla-examples/releases/latest/download/startup.sh) script yourself.
27+
:::
28+
29+
### Prerequisites
30+
31+
Before proceeding, you should have [Compose](https://docs.docker.com/compose/gettingstarted/) or optionally [Helm](https://helm.sh/docs/intro/install/) and [Kubernetes](https://kubernetes.io/docs/tasks/tools/) installed.
32+
33+
::: details Detailed prerequisites
34+
35+
- A connection to the internet
36+
- Docker version 1.13.0+ or later is installed and running
37+
- Docker Desktop or Docker Desktop for Windows on WSL 2
38+
- Container host resources: 1 CPU, 1GB memory
39+
40+
Optional:
41+
42+
- Kafka 3.0+ hosted with the Docker network allowed to communicate
43+
- Helm 3.0+
44+
- Kubernetes 1.13.0+
45+
46+
:::
47+
48+
### Check the Kafka topics
49+
50+
Run the docker command under the `Verify the Kafka topics created` section of the script output. Verify these topics are listed. Read more on the data in these topics in [the overview](../../concepts/kafka-proxies/mqtt-proxy.html#step-2-pub-sub-message-reflect-with-kafka).
51+
52+
```output:no-line-numbers
53+
mqtt-messages
54+
mqtt-retained
55+
mqtt-sessions
56+
```
57+
58+
### Listen for messages
59+
60+
Run the docker command under the `Start a topic consumer to listen for messages` section of the script output. If you didn't use your own Kafka, you can also see all the topics in the [Kafka UI](http://localhost:8080/ui/clusters/local/all-topics).
61+
62+
### Send a greeting
63+
64+
Using [eclipse-mosquitto](https://hub.docker.com/_/eclipse-mosquitto) subscribe to the `zilla` topic.
65+
66+
```bash:no-line-numbers
67+
docker run -it --rm eclipse-mosquitto \
68+
mosquitto_sub -V 'mqttv5' --topic 'zilla' \
69+
--host 'host.docker.internal' --port 7183 --debug
70+
```
71+
72+
In a separate session, publish a message on the `zilla` topic.
73+
74+
```bash:no-line-numbers
75+
docker run -it --rm eclipse-mosquitto \
76+
mosquitto_pub -V 'mqttv5' --topic 'zilla' --message 'Hello, world' \
77+
--host 'host.docker.internal' --port 7183 --debug --insecure
78+
```
79+
80+
Send messages with the retained flag.
81+
82+
```bash:no-line-numbers
83+
docker run -it --rm eclipse-mosquitto \
84+
mosquitto_pub -V 'mqttv5' --topic 'zilla' --message 'Hello, retained' --retain \
85+
--host 'host.docker.internal' --port 7183 --debug --insecure
86+
```
87+
88+
Then restart the `mosquitto_sub` above. The latest retained message is delivered, and the other messages are not.
89+
90+
## Creating this example yourself
91+
92+
### Start a Kafka instance
93+
94+
You can use your own Kafka or set up a local Kafka with [resource.kafka.compose](https://github.com/aklivity/zilla-examples/releases/latest/download/resource.kafka.compose.tar.gz) and follow the setup instructions in the `README.md`.
95+
96+
Export these env variables or overwrite them with your remote Kafka if you skipped the local setup.
97+
98+
```output:no-line-numbers
99+
export KAFKA_HOST=host.docker.internal
100+
export KAFKA_PORT=29092
101+
```
102+
103+
### Bootstrap Kafka
104+
105+
Create these topics in the Kafka environment.
106+
107+
```bash:no-line-numbers
108+
\
109+
/bin/kafka-topics.sh --bootstrap-server $KAFKA_HOST:$KAFKA_PORT --create --if-not-exists --topic mqtt-sessions
110+
/bin/kafka-topics.sh --bootstrap-server $KAFKA_HOST:$KAFKA_PORT --create --if-not-exists --topic mqtt-messages --config cleanup.policy=compact
111+
/bin/kafka-topics.sh --bootstrap-server $KAFKA_HOST:$KAFKA_PORT --create --if-not-exists --topic mqtt-retained --config cleanup.policy=compact
112+
```
113+
114+
### Create your config
115+
116+
Create a new file called `zilla.yaml` and append the below yaml to it.
117+
118+
### Entrypoint
119+
120+
This will configure Zilla for accepting all of the `mqtt` traffic.
121+
122+
```yaml{14-16}
123+
<!-- @include: ./mqtt_kafka_broker_zilla.yaml{-20} -->
124+
```
125+
126+
::: right
127+
[More on binding-tcp](../../reference/config/bindings/binding-tcp.md)
128+
[More on binding-mqtt](../../reference/config/bindings/binding-mqtt.md)
129+
:::
130+
131+
### Service definition
132+
133+
The service definitions will define how the clients using this service will interact with Kafka through Zilla.
134+
135+
```yaml{7-9}
136+
<!-- @include: ./mqtt_kafka_broker_zilla.yaml{22-31} -->
137+
```
138+
139+
::: right
140+
[More on binding-mqtt-kafka](../../reference/config/bindings/binding-mqtt-kafka.md)
141+
[More on topic data](../../concepts/kafka-proxies/mqtt-proxy.html#step-2-pub-sub-message-reflect-with-kafka)
142+
:::
143+
144+
### Add a Kafka sync layer
145+
146+
The Zilla [cache_client and cache_server](../../reference/config/bindings/binding-kafka.html#kind) helps manage the smooth data transfer between the service definition and Kafka.
147+
148+
```yaml{11-12}
149+
<!-- @include: ./mqtt_kafka_broker_zilla.yaml{33-46} -->
150+
```
151+
152+
::: right
153+
[More on binding-kafka cache](../../reference/config/bindings/binding-kafka.md#cache-behavior)
154+
:::
155+
156+
### Point to a Running Kafka instance
157+
158+
This will define the location and connection for Zilla to communicate with Kafka.
159+
160+
```yaml{10-11}
161+
<!-- @include: ./mqtt_kafka_broker_zilla.yaml{47-} -->
162+
```
163+
164+
::: details Full zilla.yaml
165+
166+
```yaml
167+
<!-- @include: ./mqtt_kafka_broker_zilla.yaml -->
168+
```
169+
170+
:::
171+
172+
::: right
173+
[More on binding-kafka client](../../reference/config/bindings/binding-kafka.md#client-behavior)
174+
:::
175+
176+
### Start Zilla
177+
178+
With your `zilla.yaml` config, follow the [Zilla install instructions](../install.md) using your method of choice. Set the necessary Kafka environment variables.
179+
180+
::: code-tabs#bash
181+
182+
@tab Docker
183+
184+
```bash:no-line-numbers
185+
--env KAFKA_HOST="$KAFKA_HOST" --env KAFKA_PORT="$KAFKA_PORT"
186+
```
187+
188+
@tab Helm values.yaml
189+
190+
```yaml:no-line-numbers
191+
# use the values from $KAFKA_HOST $KAFKA_PORT variables
192+
env:
193+
- name: KAFKA_HOST
194+
value: "\"host.docker.internal\""
195+
- name: KAFKA_PORT
196+
value: "\"29092\""
197+
```
198+
199+
:::
200+
201+
### Adding TLS
202+
203+
You can add TLS to this broker by adding a vault and tls binding as described in the [Server Encryption](../../concepts/config-intro.md#server-encryption-tls-ssl) section.
204+
205+
## Remove the running containers
206+
207+
Find the path to the `teardown.sh` script(s) in the `use the teardown script(s) to clean up` section of the example output and run it. If you didn't provide an external Kafka endpoint, there will be scripts for both Zilla and the local Kafka installs.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: zilla-mqtt-kafka-broker
3+
bindings:
4+
5+
# Proxy service entrypoint
6+
north_tcp_server:
7+
type: tcp
8+
kind: server
9+
options:
10+
host: 0.0.0.0
11+
port:
12+
- 7183
13+
routes:
14+
- when:
15+
- port: 7183
16+
exit: north_mqtt_server
17+
north_mqtt_server:
18+
type: mqtt
19+
kind: server
20+
exit: north_mqtt_kafka_mapping
21+
22+
# MQTT messages to Kafka topics
23+
north_mqtt_kafka_mapping:
24+
type: mqtt-kafka
25+
kind: proxy
26+
options:
27+
topics:
28+
sessions: mqtt-sessions
29+
messages: mqtt-messages
30+
retained: mqtt-retained
31+
exit: north_kafka_cache_client
32+
33+
# Kafka sync layer
34+
north_kafka_cache_client:
35+
type: kafka
36+
kind: cache_client
37+
exit: south_kafka_cache_server
38+
south_kafka_cache_server:
39+
type: kafka
40+
kind: cache_server
41+
options:
42+
bootstrap:
43+
- mqtt-messages
44+
- mqtt-retained
45+
exit: south_kafka_client
46+
47+
# Connect to Kafka
48+
south_kafka_client:
49+
type: kafka
50+
kind: client
51+
exit: south_tcp_client
52+
south_tcp_client:
53+
type: tcp
54+
kind: client
55+
options:
56+
host: ${{env.KAFKA_HOST}}
57+
port: ${{env.KAFKA_PORT}}
58+
routes:
59+
- when:
60+
- cidr: 0.0.0.0/0

0 commit comments

Comments
 (0)