'How to consume events from a different namespace with knative?

What is the minimum required setup to consume events from a different namespace with knative?

I have the following setup, and it doesn't work.

My Broker in ns-a:

apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
  name: default
  # namespace: ns-a

My service in ns-b namespace

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: my-service
  namespace: ns-a

---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: my-service-trigger
  namespace: ns-a
spec:
  broker: default
  subscriber:
    ref:
      apiVersion: serving.knative.dev/v1
      kind: Service
      name: my-service
      namespace: ns-b


Solution 1:[1]

I had to swap the trigger's and the subscription's namespace, and now it works as expected.

---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: my-service-trigger
  namespace: ns-b
spec:
  broker: default
  subscriber:
    ref:
      apiVersion: serving.knative.dev/v1
      kind: Service
      name: my-service
      namespace: ns-a

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TimarTimar