Creating a RedisStreamSource
This topic describes how to create a object.
RedisStreamSource
is a Knative Eventing add-on.
Install RedisStreamSource by running the command:
Verify that
redis-controller-manager
is running:kubectl get deployments.apps -n knative-sources
Example output:
NAME READY UP-TO-DATE AVAILABLE AGE
redis-controller-manager 1/1 1 1 3s
Create a Service
-
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: event-display
namespace: default
spec:
spec:
containers:
- # This corresponds to
image: gcr.io/knative-releases/knative.dev/eventing/cmd/event_display
Apply the YAML file by running the command:
Where
<filename>
is the name of the file you created in the previous step.Example output:
service.serving.knative.dev/event-display created
Ensure that the Service Pod is running, by running the command:
kubectl get pods
The Pod name is prefixed with
event-display
:NAME READY STATUS RESTARTS AGE
event-display-00001-deployment-5d5df6c7-gv2j4 2/2 Running 0 72s
- Create the
RedisStreamSource
object using the YAML template below:
<redis-stream-source>
is the name of your source. (required)<redis-uri>
is the Redis URI. See the for more information. (required)<redis-stream-name>
is the name of the Redis stream. (required)<consumer-group-name>
is the name of the Redis consumer group. When left empty a group is automatically created for this source, and deleted when this source is deleted. (optional)<sink>
is where to send events. (required)Apply the YAML file by running the command:
Where
<filename>
is the name of the file you created in the previous step.
Verify the RedisStreamSource object
View the logs for the
event-display
event consumer by running the command:Sample output:
☁️ cloudevents.Event
Validation: valid
Context Attributes,
specversion: 1.0
type: dev.knative.sources.redisstream
source: /mystream
id: 1597775814718-0
time: 2020-08-18T18:36:54.719802342Z
datacontenttype: application/json
Data,
[
"fruit",
"banana"
"color",
"yellow"
]
Additional information
- For more information about Redis Stream source, see the