Body: <p>I have a url like this:  <code>http://myserver.mydomain.com:98765</code></p>
  <p>I need to have this url be a Kubernetes service so I can address it in Kubernetes like this: <code>my-service.mynamespace.svc.cluster.local</code>.  (So, if I run <code>curl http://my-service.mynamespace.svc.cluster.local/metrics</code> from inside my cluster, it will return the same value as calling <code>curl https://myserver.mydomain.com:98765/metrics</code>.)</p>
  <p>I have tried to make a <code>Service</code> of type <code>ExternalName</code>.  But external name cannot support ports.  So instead, I have to run: <code>curl http://my-service.mynamespace.svc.cluster.local:98765/metrics</code>  (that does not work for what I am doing).</p>
  <p>I also looked into using a &quot;headless service&quot; with a Kubernetes <code>Endpoint</code>.  This looks like it will allow me to specify a port, but an <code>Endpoint</code> only supports using IP addresses.  My company frowns on hardcoding IP addresses.  So that solution is not very good either.</p>
  <p><strong>Is there a way to use a host name AND use a port when making a Kubernetes service that accesses an external URL?</strong></p>
  <p>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.</p>
  
Comments: CC BY-SA 4.0
Comments: 2021-10-13T13:07:30.050Z
Comments: see attached link, this is what you need? an endpoint https://stackoverflow.com/questions/69368058/how-can-i-proxy-an-external-site-through-my-kubernetesopenshift-ingress/69368157#69368157
Comments: Siddique Ahmad
Comments: CC BY-SA 4.0
Comments: 2021-10-14T16:17:44.180Z
Comments: @SiddiqueAhmad - Thank you for looking into my issue.  Unfortunately, that uses `Endpoints`, which only supports IP addresses.
Comments: Vaccano
Tags: <kubernetes><prometheus>
Title: Create a Kubernetes Service that loads an external host url AND port
UserDisplayName: Vaccano
ThreadText: # Create a Kubernetes Service that loads an external host url AND port
  
  (Asked by: username_0 on 2021-10-12)
  
  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.
  
  **Tags:** kubernetes, prometheus
  
  > **Comments:**
  > **username_1**: see attached link, this is what you need? an endpoint https://stackoverflow.com/questions/69368058/how-can-i-proxy-an-external-site-through-my-kubernetesopenshift-ingress/69368157#69368157  
  > **username_0**: @username_1 - Thank you for looking into my issue.  Unfortunately, that uses `Endpoints`, which only supports IP addresses.  
  
  ---
  
  ## 0 answers
  
  