7

I am trying to get the list of pods that are servicing a particular service

There are 3 pods associated with my service.

I tried to execute the below command

oc describe svc my-svc-1

I am expecting to see the pods associated with this service. but that does not show up. What command gets me just the list of pods associated with the service.

Arghya Sadhu
  • 41,002
  • 9
  • 78
  • 107
lr-pal
  • 339
  • 2
  • 6
  • 20

1 Answers1

8

A service chooses the pods using the selector. Look at the selector for the service, and get the pods using that selector. For kubectl, the command looks like:

kubectl get pods --selector <selector>
Burak Serdar
  • 46,455
  • 3
  • 40
  • 59
  • Another question, Can you suggest how do i list the services ending with a certain string. i am trying to do this ```oc get services --name "*dev"``` and it didnt work – lr-pal Aug 24 '19 at 05:09
  • 1
    I do not know a built-in mechanism to do that. I'd use grep for such things. – Burak Serdar Aug 24 '19 at 05:20