Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broker and source docs improvements #555

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ See [Install and Demo](./broker/README.md)

## RabbitMQ Source

See [Install and Demo](./source/README.adoc)
See [Install and Demo](./source/README.md)

---

Expand Down
110 changes: 20 additions & 90 deletions broker/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
# RabbitMQ Knative Eventing Broker

RabbitMQ *is a Messaging Broker* - an intermediary for messaging. It gives your applications a common platform to send and receive messages, and your messages a safe place to live until received.
gabo1208 marked this conversation as resolved.
Show resolved Hide resolved

![RabbitMQ Broker for Knative Eventing](rabbitmq-knative-broker.png)

# Table of Contents

- [Installation](#installation)
- [Standalone Broker](#standalone-broker)
- [RabbitMQ Operator Based Broker](#rabbitmq-operator-based-broker)
- [Autoscaling](#autoscaling-optional)
- [Next Steps](#next-steps)
- [Additional Resources](#additional-resources)

## Installation

We provide two versions of the RabbitMQ Knative Eventing Broker.

1. Standalone Broker
2. RabbitMQ operator based Broker
1. [Standalone Broker](#standalone-broker)
2. [RabbitMQ operator based Broker](#rabbitmq-operator-based-broker)

### Standalone Broker

This Broker works by utilizing libraries to manage RabbitMQ resources directly and as name implies does not have have dependencies on other operators. Choose this if you do not manage your clusters lifecycle with the [Cluster Operator](https://github.com/rabbitmq/cluster-operator).

[Install Standalone Broker](./standalone.md)

### RabbitMQ operator based Broker
### RabbitMQ Operator Based Broker

This Broker builds on top of [Cluster Operator](https://github.com/rabbitmq/cluster-operator) and [Messaging Topology Operator](https://github.com/rabbitmq/messaging-topology-operator). As such it requires both of them to be installed. This Broker also will only work with RabbitMQ clusters created and managed by the Cluster Operator and as such if you do not manage your RabbitMQ clusters with it, you must use the [Standalone Broker](./standalone.md).

Expand All @@ -29,90 +38,11 @@ To get autoscaling (scale to zero as well as up from 0), you can also optionally
install
[KEDA based autoscaler](https://github.com/knative-sandbox/eventing-autoscaler-keda).

## Demo

### Create a Broker

Depending on which version of the controller you are running, create a broker either for [standalone](./standalone.md#creating-knative-eventing-broker) or [operator based](./operator-based.md#creating-knative-eventing-broker).

### Create a Knative Trigger

Next you need to create a Trigger, specifying which events get routed to where.
For this example, we use a simple PingSource, which generates an event once a
minute.

```
kubectl apply -f - << EOF
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: ping-trigger
namespace: default
spec:
broker: default
filter:
attributes:
type: dev.knative.sources.ping
subscriber:
ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: subscriber
EOF
```

Create a Ping Source by executing the following command:

```
kubectl apply -f - << EOF
apiVersion: sources.knative.dev/v1
kind: PingSource
metadata:
name: ping-source
spec:
schedule: "*/1 * * * *"
data: '{"message": "Hello world!"}'
sink:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: default
EOF
```

Create an event_display subscriber:

```
kubectl apply -f - << EOF
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: subscriber
namespace: default
spec:
template:
spec:
containers:
- image: gcr.io/knative-releases/knative.dev/eventing/cmd/event_display
EOF
```

tail the logs on the subscriber's depoyment, and you should see a "Hello world!"
event once per minute; for example using [kail](https://github.com/boz/kail):

```sh
$ kail -d subscriber-4kf8l-deployment
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: ☁️ cloudevents.Event
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: Validation: valid
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: Context Attributes,
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: specversion: 1.0
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: type: dev.knative.sources.ping
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: source: /apis/v1/namespaces/default/pingsources/ping-source
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: id: 1fec78d7-20c2-459f-ac5e-8a797ca7bcdd
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: time: 2020-05-13T17:19:00.000374701Z
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: datacontenttype: application/json
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: Data,
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: {
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: "message": "Hello world!"
default/subscriber-4kf8l-deployment-8d556d6cd-j669x[user-container]: }
```
## Next Steps

Check out the [Broker-Trigger Samples Directory](../samples/broker-trigger) in this repo and start building your topology with Eventing RabbitMQ!

## Additional Resources
gabo1208 marked this conversation as resolved.
Show resolved Hide resolved

- [RabbitMQ Docs](https://www.rabbitmq.com/documentation.html)
- [Knative Docs](https://knative.dev/docs/)
6 changes: 2 additions & 4 deletions broker/operator-based.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ kubectl apply -f - << EOF
EOF
```

## Next step
## Next steps

Now that you have Knative Eventing integrated with RabbitMQ, a good next step
is to use it with the [CloudEvents Player Source](https://knative.dev/docs/getting-started/first-source/)
so that you can get a better understanding of how it all fits together.
- Now that you have Knative Eventing integrated with RabbitMQ, a good next step is to use it with the [CloudEvents Player Source](https://knative.dev/docs/getting-started/first-source/) so that you can get a better understanding of how it all fits together.
4 changes: 4 additions & 0 deletions samples/broker-trigger/100-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: broker-trigger-demo
8 changes: 8 additions & 0 deletions samples/broker-trigger/200-rabbitmq.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# RabbitMQ cluster used by the Broker
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
name: rabbitmq
namespace: broker-trigger-demo
spec:
replicas: 1
20 changes: 20 additions & 0 deletions samples/broker-trigger/300-broker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
name: default
namespace: broker-trigger-demo
annotations:
eventing.knative.dev/broker.class: RabbitMQBroker
spec:
config:
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
name: rabbitmq
delivery:
deadLetterSink:
ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: event-display
namespace: broker-trigger-demo
retry: 5
10 changes: 10 additions & 0 deletions samples/broker-trigger/400-sink.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: event-display
namespace: broker-trigger-demo
spec:
template:
spec:
containers:
- image: gcr.io/knative-releases/knative.dev/eventing/cmd/event_display
29 changes: 29 additions & 0 deletions samples/broker-trigger/500-ping-sources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: sources.knative.dev/v1
kind: PingSource
metadata:
name: ping-source
namespace: broker-trigger-demo
spec:
schedule: "*/1 * * * *"
data: '{"responsecode": 200}'
sink:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: default
namespace: broker-trigger-demo
---
apiVersion: sources.knative.dev/v1
kind: PingSource
metadata:
name: ping-source-2
namespace: broker-trigger-demo
spec:
schedule: "*/1 * * * *"
data: '{"responsecode": 500}'
sink:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: default
namespace: broker-trigger-demo
21 changes: 21 additions & 0 deletions samples/broker-trigger/600-trigger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: failer-trigger
namespace: broker-trigger-demo
annotations:
# Value must be between 1 and 1000
# A value of 1 RabbitMQ Trigger behaves as a FIFO queue
# Values above 1 break message ordering guarantees and can be seen as more performance oriented.
rabbitmq.eventing.knative.dev/prefetchCount: "10"
spec:
broker: default
filter:
attributes:
type: dev.knative.sources.ping
subscriber:
ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: failer
namespace: broker-trigger-demo
15 changes: 15 additions & 0 deletions samples/broker-trigger/700-failer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: failer
namespace: broker-trigger-demo
labels:
rabbitmq.eventing.knative.dev/release: "v20211216-d49cd0f2"
spec:
template:
spec:
containers:
- image: gcr.io/knative-nightly/knative.dev/eventing-rabbitmq/cmd/failer@sha256:6dbe9157b9b74fbcde84091d43d65ec1b827b5d86a4670128867f1cb777bfb56
env:
- name: DEFAULT_RESPONSE_CODE
value: "200"
Loading