<p>I have a server that is orchestrated using k8s it's service looks like below</p>

<pre><code>➜  installations ✗ kubectl get svc
NAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                               AGE

oxd-server           ClusterIP   10.96.124.25   &lt;none&gt;        8444/TCP,8443/TCP                     3h32m
</code></pre>

<p>and it's pod.</p>

<pre><code>➜  helm git:(helm-rc1) ✗ kubectl get po
NAME                                   READY   STATUS             RESTARTS   AGE

sam-test-oxd-server-6b8f456cb6-5gwwd   1/1     Running            0          3h2m

</code></pre>

<p>Now, I have a docker image with an <code>env</code> variable that requires the URL of this server. </p>

<p>I have 2 questions from here.</p>

<ol>
<li><p>How can the docker image get the URL or access the URL? </p></li>
<li><p>How can I access the same URL in my terminal so I make some curl commands through it?</p></li>
</ol>

<p>I hope I am clear on the explanation.</p>

Shammir
<p>If your docker container is outside the kubernetes cluster, then it's not possible to access you <code>ClusterIP</code> service.</p>

<p>As you could guess by its name, <code>ClusterIP</code> type services are only accessible <strong>from within the cluster</strong>.<br>
By <em>within the cluster</em> I mean any resource managed by Kubernetes.<br>
<em>A standalone docker container running inside a VM which is part of your K8S cluster is not a resource managed by K8S.</em></p>

<p>So, in order to achieve what you want, you'll have those possibilities :</p>

<ol>
<li>Set a <code>hostPort</code> inside your pod. This is not recommanded and is listed as a bad practice in the <a href="https://kubernetes.io/docs/concepts/configuration/overview/#services" rel="nofollow noreferrer">doc</a>. Keep this usage for very specific case.</li>
<li>Switch your service to <code>NodePort</code> instead of <code>ClusterIP</code>. This way, you'll be able to access it using a node IP + the node port.</li>
<li>Use a <code>LoadBalancer</code> type of service, but this solution needs some configuration and is not straightforward.</li>
<li>Use an <code>Ingress</code> along with an <code>IngressController</code> but just like the load balancer, this solution needs some configuration and is not that straightforward.</li>
</ol>

<p>Depending on what you do and if this is critical or not, you'll have to choose one of these solutions. </p>

<ul>
<li>1 &amp; 2 for debug/dev</li>
<li>3 &amp; 4 for prod, but you'll have to work with your k8s admin</li>
</ul>
