knative / client

Knative developer experience, docs, reference Knative CLI implementation
Apache License 2.0
351 stars 263 forks source link

Can not get my broker through `kn broker list` #1863

Closed fabian4 closed 1 year ago

fabian4 commented 1 year ago

https://knative.dev/docs/eventing/brokers/create-broker/

// create a broker
kn broker create eventmesh -n knative-eventing
➜  ~ kn broker list
No brokers found.
➜  ~ kn broker list -o json

{
    "apiVersion": "eventing.knative.dev/v1",
    "items": [],
    "kind": "BrokerList"
}
➜  ~ kubectl describe broker eventmesh -n knative-eventing
Name:         eventmesh
Namespace:    knative-eventing
Labels:       <none>
Annotations:  eventing.knative.dev/broker.class: MTChannelBasedBroker
              eventing.knative.dev/creator: system:admin
              eventing.knative.dev/lastModifier: system:admin
API Version:  eventing.knative.dev/v1
Kind:         Broker
Metadata:
  Creation Timestamp:  2023-09-05T13:26:29Z
  Generation:          1
  Resource Version:    1228058
  UID:                 6bff2ca4-8f8b-470d-acdb-9267f4a103a2
Spec:
  Config:
    API Version:  v1
    Kind:         ConfigMap
    Name:         config-br-default-channel
    Namespace:    knative-eventing
  Delivery:
    Backoff Delay:   PT0.2S
    Backoff Policy:  exponential
    Retry:           10
Status:
  Address:
    Name:  http
    URL:   http://broker-ingress.knative-eventing.svc.cluster.local/knative-eventing/eventmesh
  Annotations:
    knative.dev/channelAPIVersion:  messaging.knative.dev/v1
    knative.dev/channelAddress:     http://eventmesh-kne-trigger-kn-channel.knative-eventing.svc.cluster.local
    knative.dev/channelKind:        InMemoryChannel
    knative.dev/channelName:        eventmesh-kne-trigger
  Conditions:
    Last Transition Time:  2023-09-05T13:26:29Z
    Status:                True
    Type:                  Addressable
    Last Transition Time:  2023-09-05T13:26:29Z
    Message:               No dead letter sink is configured.
    Reason:                DeadLetterSinkNotConfigured
    Severity:              Info
    Status:                True
    Type:                  DeadLetterSinkResolved
    Last Transition Time:  2023-09-05T13:26:29Z
    Status:                True
    Type:                  FilterReady
    Last Transition Time:  2023-09-05T13:26:29Z
    Status:                True
    Type:                  IngressReady
    Last Transition Time:  2023-09-05T13:26:29Z
    Status:                True
    Type:                  Ready
    Last Transition Time:  2023-09-05T13:26:29Z
    Status:                True
    Type:                  TriggerChannelReady
  Observed Generation:     1
Events:                    <none>
➜  ~
fabian4 commented 1 year ago

let me know if you need something else

rhuss commented 1 year ago

What do you see with kn broker list -n knative-eventing ? (i.e. with providing the namespace)

Another question would be, why are you creating the broker in the knative-eventing namespace ? This namespace is usually reserved for the Knative eventing control-plane and data-plane, brokers CRs are typically created in the user namespace where your workload is deployed.

fabian4 commented 1 year ago
➜  ~ kn broker list
No brokers found.
➜  ~
➜  ~
➜  ~ kn broker list -n knative-eventing
NAME        URL                                                                                   AGE   CONDITIONS   READY   REASON
eventmesh   http://broker-ingress.knative-eventing.svc.cluster.local/knative-eventing/eventmesh   40h   6 OK / 6     True
➜  ~

Another question would be, why are you creating the broker in the knative-eventing namespace ? This namespace is usually reserved for the Knative eventing control-plane and data-plane, brokers CRs are typically created in the user namespace where your workload is deployed.

I just create a broker for testing, and choose the namespace directlly. May that be the root cause?

dsimansk commented 1 year ago

The culprit is that your current namespace is probably default, but cmd for kn with -n option created the broker resource in the specified namespace.

By default kn inherits current namespace value from the active kubectl context, when not provided explicitly. Hence usually it's default for fresh clusters, e.g. on Minikube or Kind. You can work with namespace as with any other K8s resource though.

Note: if you look around for namespace plugins for kubectl. There are a few options that makes switching between namespaces a bit more user-friendly. https://github.com/ahmetb/kubectx

➜  ~ kubectl get ns
NAME                 STATUS   AGE
default              Active   3m41s
knative-eventing     Active   2m56s
knative-serving      Active   3m32s
kourier-system       Active   3m24s
kube-node-lease      Active   3m41s
kube-public          Active   3m41s
kube-system          Active   3m41s
local-path-storage   Active   3m36s
test-ns              Active   2m31s

➜  ~ kubectl create ns test-ns

# Switch active context to a different namespace
➜  ~  kubectl config set-context --current --namespace=test-ns
Context "kind-kind" modified.

# Check current namespace in the active context
➜  ~ kubectl config view --minify | grep namespace:
    namespace: test-ns

See K8s docs for more: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

fabian4 commented 1 year ago
➜  ~ kn broker list -n knative-eventing
NAME        URL                                                                                   AGE   CONDITIONS   READY   REASON
eventmesh   http://broker-ingress.knative-eventing.svc.cluster.local/knative-eventing/eventmesh   42h   6 OK / 6     True
➜  ~
➜  ~ kn broker list
No brokers found.
➜  ~
➜  ~ kubectl config set-context --current --namespace=knative-eventing
Context "default" modified.
➜  ~
➜  ~ kn broker list
NAME        URL                                                                                   AGE   CONDITIONS   READY   REASON
eventmesh   http://broker-ingress.knative-eventing.svc.cluster.local/knative-eventing/eventmesh   42h   6 OK / 6     True
➜  ~

Thanks a lot. It really helps me to understand it better.

dsimansk commented 1 year ago

Thanks a lot. It really helps me to understand it better.

You're welcome! I'm glad we could work it out together. Please don't hesitate to raise any other issues you come across when exploring Knative.