2

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.

0_o
  • 487
  • 4
  • 14

1 Answers1

6

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
Const
  • 6,237
  • 3
  • 22
  • 27