1

I have a url like this: http://myserver.mydomain.com:98765

I need to have this url be a Kubernetes service so I can address it in Kubernetes like this: my-service.mynamespace.svc.cluster.local. (So, if I run curl http://my-service.mynamespace.svc.cluster.local/metrics from inside my cluster, it will return the same value as calling curl https://myserver.mydomain.com:98765/metrics.)

I have tried to make a Service of type ExternalName. But external name cannot support ports. So instead, I have to run: curl http://my-service.mynamespace.svc.cluster.local:98765/metrics (that does not work for what I am doing).

I also looked into using a "headless service" with a Kubernetes Endpoint. This looks like it will allow me to specify a port, but an Endpoint only supports using IP addresses. My company frowns on hardcoding IP addresses. So that solution is not very good either.

Is there a way to use a host name AND use a port when making a Kubernetes service that accesses an external URL?

In case anyone wants know what this for, I have a Rabbit MQ server (external to Kubernetes) that exposes prometheus metrics. I need to wrap that in a Kubernetes service so that my Prometheus operator can find the service with a label on it and pull the metrics in.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.