Knative: Operator’s Handbook

Exploring Kubernetes object hierarchy

When you create a Knative Service, sometimes you need to debug which Kubernetes, Istio etc. resources are created to make it work. Then you can browse those resources (such as Pod, Service, Istio VirtualService…) to debug the issue.

You can use kni (knative-inspect) tool to find the parent-child relationships between the Kubernetes objects created as a result of your Knative Service. Install this tool:

$ go get github.com/nimakaviani/knative-inspect/cmd/kni
$ kni inspect -s hello
NAME                                 KIND                       READY
hello                                KService                   True
hello                                 ├─ Configuration          True
hello-0001                            │ └─ Revision             True
hello-0001-deployment                 │  ├─ Deployment          -
hello-0001-deployment-578bd           │  │ └─ ReplicaSet        -
hello-0001-deployment-57ffd-vr47v     │  │  └─ Pod              True
hello-0001-cache                      │  ├─ Image               -
hello-0001                            │  └─ PodAutoscaler       True
hello-0001-metrics                    │   ├─ Service            -
hello-0001                            │   ├─ Metric             True
hello-0001                            │   └─ ServerlessService  True
hello-0001-j68v6                      │    ├─ Service           -
hello-0001                            │    ├─ Service           -
hello-0001                            │    └─ Endpoints         -
hello                                 └─ Route                  True
hello                                   ├─ Service              -
hello                                   └─ Ingress              True
hello-mesh                                 ├─ VirtualService    -
hello                                      └─ VirtualService    -

This command will show you which objects are owned by which objects, and it will show their status and Kubernetes events. You can use this tool to debug why a service might be broken.