Skip to content

Instantly share code, notes, and snippets.

@matzew
Created May 13, 2020 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzew/053f28c252374bbe98e21cc45b7beab6 to your computer and use it in GitHub Desktop.
Save matzew/053f28c252374bbe98e21cc45b7beab6 to your computer and use it in GitHub Desktop.

Creating Knative default Broker as non admin user

Create a consuming service:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: broker-display1
spec:
  template:
    spec:
      containers:
      - image: quay.io/matzew/event-display

The Source

Now, create a source. The ping source:

apiVersion: sources.knative.dev/v1alpha2
kind: PingSource
metadata:
  name: ping-source
spec:
  schedule: "*/1 * * * *"
  jsonData: '{"message": "Hello world!"}'
  sink:
    ref:
      apiVersion: eventing.knative.dev/v1beta1
      kind: Broker
      name: default

NOTE: The source emits events to a Broker, called default. This broker is not yet there, therefore we do not immediately see a pod for the source being created.

The Broker

In order to create the broker there are a few ways for the admin (TODO add link for all the other content).

However for a normal user, it is possible to create a default broker as well. The trick is to use the ``knative-eventing-injection: enable Annotation on the trigger object.

Apply the trigger:

apiVersion: eventing.knative.dev/v1beta1
kind: Trigger
metadata:
  annotations:
    knative-eventing-injection: enabled
  name: testevents-trigger
spec:
  broker: default
  subscriber:
    ref:
      apiVersion: serving.knative.dev/v1
      kind: Service
      name: broker-display1

Now, this will cause the two broker pods (filter and ingress) to come up. As well as the pod for the source, since it has now a reachable sink (the broker).

Pods will be like:

NAME                                                              READY   STATUS    RESTARTS   AGE
broker-display1-2rxhn-deployment-745bb69dff-2zd55                 2/2     Running   0          47s
default-broker-filter-7d89b8d949-xn6l4                            1/1     Running   0          10m
default-broker-ingress-6898597cfb-m4dct                           1/1     Running   0          10m
pingsource-ping-source-c5edff91-bb73-4f72-90fd-8b449dac8256grkq   1/1     Running   0          10m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment