Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter Kubernetes API by pod name

I have a Kubernetes cluster running in minikube, I want to filter out all Logstash pods via Kubernetes API. Kubernetes API documentation is a bit confusing, I did some research and found out that I can use something like this, but I have been unsuccessful so far:

localhost:8000/api/v1/namespaces/default/pods?labelSelector=logstash

any ideas how to retrieve this? Any help would be really appreciated.

like image 937
0_o Avatar asked Jun 11 '26 23:06

0_o


1 Answers

any ideas how to retrieve this?

Since labels are defined in <name>=<value> pairs you need to supply both, as described in the documentation (see the API section)

As an example, supposing you have:

  • namepace: default
  • labels on pods you want to select:
    • role=ops
    • application=logstash
  • kubectl proxy runs on localhost:8000

Then your api call would look like this:

curl localhost:8000/api/v1/namespaces/default/pods?labelSelector=role%3Dops,application%3Dlogstash
like image 77
Const Avatar answered Jun 15 '26 05:06

Const



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!