Any way to list all ingress paths?

7,397 views
Skip to first unread message

David Rosenstrauch

unread,
Apr 12, 2018, 11:26:36 AM4/12/18
to Kubernetes user discussion and Q&A
Is there any way to produce a comprehensive list of all the paths that
are defined in the ingress controller? (And all the services they map to.)

The closest thing I've found is:

kubectl describe ing

But that generates a lot of verbose output.

Thanks,

DR

Timo Reimann

unread,
Apr 13, 2018, 4:28:43 AM4/13/18
to Kubernetes user discussion and Q&A
I tend to struggle with jsonpath, so here's my jq-based suggestion:

$ kubectl get ing -o json | jq -r '.items[].spec.rules[].http.paths[]'

This yields a structure like

{
  "backend": {
    "serviceName": "service-foo",
    "servicePort": 80
  },
  "path": "/service-foo/path"
}
{
  "backend": {
    "serviceName": "service-bar",
    "servicePort": 443
  },
  "path": "/service-bar/path"
}

for me. You can tweak the jq expression for extra slicing and dicing.

HTH

Timo

David Rosenstrauch

unread,
Apr 13, 2018, 10:19:58 AM4/13/18
to 'Timo Reimann' via Kubernetes user discussion and Q&A
Ooh, good answer. I was thinking more along the lines of something that
kubectl provided natively, but json output plus the jq parser (which I
love and use all the time) definitely fits the bill.

Along those lines, I've been using a more low-tech/hacky version up till
now:

kubectl describe ing | grep " /"

Thanks,

DR

On 04/13/2018 04:28 AM, 'Timo Reimann' via Kubernetes user discussion

Timo Reimann

unread,
Apr 14, 2018, 5:27:55 AM4/14/18
to Kubernetes user discussion and Q&A
I actually first tried to provide a solution that works with jsonpath alone. Unfortunately, the union operator never does what I'd ideally like it to do.

Whoever reads this and knows a kubectl-only approach, please raise your voice. :-)

Reply all
Reply to author
Forward
0 new messages