Skip to content

Commit

Permalink
added readme to source sample
Browse files Browse the repository at this point in the history
transforming source adoc to md

finished source readme.md

modified docs for the broker

added some extra info and fixed typo

fixed style error in yaml

added some extra info and fixed typo

removing trailing spaces from source sample readme
  • Loading branch information
gabo1208 committed Dec 17, 2021
1 parent 82dc6ae commit f8d0ca4
Show file tree
Hide file tree
Showing 11 changed files with 377 additions and 288 deletions.
108 changes: 19 additions & 89 deletions broker/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# 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.

![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)
- [Next Steps](#next-steps)
- [Additional Resources](#additional-resources)

## Installation

We provide two versions of the RabbitMQ Knative Eventing Broker.

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

### Standalone Broker
Expand All @@ -17,7 +26,7 @@ This Broker works by utilizing libraries to manage RabbitMQ resources directly a

[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

- [RabbitMQ Docs](https://www.rabbitmq.com/documentation.html)
- [Knative Docs](https://knative.dev/docs/)
2 changes: 1 addition & 1 deletion samples/broker-trigger/600-trigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ spec:
apiVersion: serving.knative.dev/v1
kind: Service
name: failer
namespace: broker-trigger-demo
namespace: broker-trigger-demo
8 changes: 4 additions & 4 deletions samples/broker-trigger/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# RabbitMQ Knative Eventing Broker DLQ Example
# RabbitMQ Knative Eventing Broker with Trigger and DLQ Example

## Prerequisites

install the Broker as per [here](../../../broker/README.md)
install the Broker as per [here](../../broker/README.md)

## Overview

Expand All @@ -12,7 +12,7 @@ Sink while successfully processed events do not.

## Components

- [failer](../../../cmd/failer/main.go) is a function which takes in a
- [failer](../../cmd/failer/main.go) is a function which takes in a
CloudEvent and depending on what the specified HTTP response code in the
message data is will respond with that. So, to simulate a failure, we just
send it a CloudEvent with a payload of 500 and it's going to simulate a
Expand All @@ -25,7 +25,7 @@ Sink while successfully processed events do not.
- [event-display](https://github.com/knative/eventing/tree/master/cmd/event_display]
which is a tool that logs the CloudEvent that it receives formatted nicely.

- [RabbitMQ Broker](../../../broker/README.md)
- [RabbitMQ Broker](../../broker/README.md)

## Configuration

Expand Down
2 changes: 1 addition & 1 deletion samples/source/100-namespace.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: concurrent-dispatch
name: source-demo
2 changes: 1 addition & 1 deletion samples/source/200-rabbitmq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
name: rabbitmq
namespace: concurrent-dispatch
namespace: source-demo
spec:
replicas: 1
2 changes: 1 addition & 1 deletion samples/source/300-perf-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: rabbitmq-perf-test
namespace: concurrent-dispatch
namespace: source-demo
spec:
replicas: 1
selector:
Expand Down
2 changes: 1 addition & 1 deletion samples/source/400-sink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: rabbitmq-source-sink
namespace: concurrent-dispatch
namespace: source-demo
spec:
template:
spec:
Expand Down
4 changes: 2 additions & 2 deletions samples/source/500-source.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: sources.knative.dev/v1alpha1
kind: RabbitmqSource
metadata:
name: rabbitmq-source
namespace: concurrent-dispatch
namespace: source-demo
spec:
brokers: "rabbitmq:5672/"
topic: ""
Expand Down Expand Up @@ -44,4 +44,4 @@ spec:
apiVersion: serving.knative.dev/v1
kind: Service
name: rabbitmq-source-sink
namespace: concurrent-dispatch
namespace: source-demo
171 changes: 171 additions & 0 deletions samples/source/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# RabbitMQ Knative Eventing Source Example

## Prerequisites

install the Source as per [here](../../source/DEVELOPMENT.md)

## Overview

What this demo shows is how the RabbitMQ Source translates messages in any format (in this case json) sent to a RabbitMQ Exchange into [CloudEvents](https://cloudevents.io/), showing the basic topology that it useas and how it handles different workloads. It's recommended for the dev to play with the Source's config parameters, shown [here](../../source/README.adoc)

## Components

- [perf-test](https://github.com/rabbitmq/rabbitmq-perf-test) RabbitMQ has a throughput testing tool, PerfTest, that is based on the Java client and can be configured to simulate from basic to advanced workloads of messages flowing to a RabbitMQ Cluster.

- [event-display](https://github.com/knative/eventing/tree/master/cmd/event_display]
which is a tool that logs the CloudEvent that it receives formatted nicely.

- [RabbitMQ Source](../../source/README.adoc)

## Configuration

Demo creates a `PerfTest` and has it send 1 event for 30 seconds, and then 0 events for 30 seconds to the `RabbitMQ Cluster` `eventing-rabbitmq-source` `Exchange`, this in a loop.

Demo creates a `Source` with and exchange configuration for it to read messages from the `eventing-rabbitmq-source` `Exchange` and to send them to the `event-display` `sink` after the translation to CloudEvents.

## Steps

### Create a namespace

Create a new namespace for the demo. All the commands are expected to be
executed from the root of this repo.

```sh
kubectl apply -f samples/source/100-namespace.yaml
```
or
```sh
kubectl create ns source-demo
```

### Create a RabbitMQ Cluster

Create a RabbitMQ Cluster:

```sh
kubectl apply -f samples/source/200-rabbitmq.yaml
```
or
```
kubectl apply -f - << EOF
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
name: rabbitmq
namespace: source-demo
spec:
replicas: 1
EOF
```

### Create the Perf Test Service

This will send events to the RabbitMQ Cluster Exchange

```sh
kubectl apply -f samples/source/300-perf-test.yaml
```

Right now, the events are not been sent to the Exchange cause the Source is not created, and is the Source the one that creates the Exchange, Channel and Queues needed for the message Translation to CloudEvents

### Create the RabbitMQ Source's Sink

Then create the Knative Serving Service which will receive translated events.

```sh
kubectl apply -f samples/source/400-sink.yaml
```
or
```sh
kubectl apply -f - << EOF
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: event-display
namespace: source-demo
spec:
template:
spec:
containers:
- image: gcr.io/knative-releases/knative.dev/eventing/cmd/event_display
EOF
```

### Create the RabbitMQ Source

```sh
kubectl apply -f samples/source/500-source.yaml
```
or
```sh
kubectl apply -f - << EOF
apiVersion: sources.knative.dev/v1alpha1
kind: RabbitmqSource
metadata:
name: rabbitmq-source
namespace: source-demo
spec:
brokers: "rabbitmq:5672/"
topic: ""
user:
secretKeyRef:
name: rabbitmq-default-user
key: username
password:
secretKeyRef:
name: rabbitmq-default-user
key: password
channel_config:
global_qos: false
exchange_config:
name: "eventing-rabbitmq-source"
type: "fanout"
durable: false
auto_deleted: false
internal: false
nowait: false
queue_config:
name: "eventing-rabbitmq-source"
routing_key: ""
durable: false
delete_when_unused: true
exclusive: true
nowait: false
sink:
ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: rabbitmq-source-sink
namespace: source-demo
EOF
```

### Check the results

Check the rabbitmq-source-sink (the Dead Letter Sink) to see if it is receiving events.
It may take a while for the Source to start sending events to the Sink, so be patient :p!

```sh
kubectl -n source-demo -l='serving.knative.dev/service=rabbitmq-source-sink' logs -c user-container
☁️ cloudevents.Event
Context Attributes,
specversion: 1.0
type: dev.knative.rabbitmq.event
source: /apis/v1/namespaces/source-demo/rabbitmqsources/rabbitmq-source
subject: f147099d-c64d-41f7-b8eb-a2e53b228349
id: f147099d-c64d-41f7-b8eb-a2e53b228349
time: 2021-12-16T20:11:39.052276498Z
datacontenttype: application/json
Data,
{
...
Random Data
...
}
```

### Cleanup

```sh
kubectl delete ns source-demo
```
Loading

0 comments on commit f8d0ca4

Please sign in to comment.