How to make http call to an application running inside a kubernetes pod from outside?

5/29/2019

I am trying to write a utility which accepts following parameters -

  1. kubernetes service name
  2. spring boot actuator endpoint name (e.g. /actuator/loggers)

This utility should invoke the endpoint on all the pods of this service.

Currently I am obtaining the name of all the pods through service name and iterating over all of them and meeting the requirement by running -

`kubectl exec $pod -- curl http:\\localhost:8081\actuator\loggers`

Though it works, I am looking for a solution where I don't have to do "exec" on the pod as I am not sure of the permission the user may have who runs this utility. Is there any way to make http call to individual pods?

-- nakul shukla
kubernetes
kubernetes-pod
spring-boot
spring-boot-actuator

1 Answer

5/29/2019

I would run this utility inside the kubernetes cluster, and expose this utility to the developers that need the data. That way you only have to expose this utility, rather than exposing all the pods to allow http calls. I think it's much simpler this way.

There are different ways to expose a Kubernetes Pod to outside the cluster, but I'd recommend using Ingress, which uses a nginx proxy to route traffic coming from outside to your pod.

-- Jose Armesto
Source: StackOverflow