<p>I have learn that I need to create a service so the deployment pods's ports will be exposed in the cluster. so the service provides me the port, and all is left is to find the cluster ip.</p>

<h3>Problem</h3>

<p>using <a href="https://github.com/kubernetes-client/javascript" rel="nofollow noreferrer">https://github.com/kubernetes-client/javascript</a>, I have created a deployment and a service.</p>

<h3>Question</h3>

<p>I'm not sure how to get the master address.</p>

<p>In bash, I would do:</p>

<pre><code>&gt; kubectl cluster-info
Kubernetes master is running at https://&lt;this-is-what-I-need&gt;:8443
KubeDNS is running at https://&lt;this-is-what-I-need&gt;:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
</code></pre>

<p>but I'm not sure how to extract the ip. is there a better bash command? or any api for that? (maybe in <a href="https://github.com/kubernetes-client/javascript" rel="nofollow noreferrer">https://github.com/kubernetes-client/javascript</a>)?</p>

<hr>

<h3>more context</h3>

<p>I created a demployment on my local machine for a docker image that exposes a service on port <code>4873</code>. </p>

<pre><code>&gt; kubectl get service stav-service1
NAME            TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
stav-service1   NodePort   10.104.10.251   &lt;none&gt;        4873:30219/TCP   39m

&gt; kubectl get deployment stav-deployment1
NAME               READY   UP-TO-DATE   AVAILABLE   AGE
stav-deployment1   1/1     1            1           41m
</code></pre>

<p>I can reach that service from my local machine by running <code>curl http://192.168.64.2:30219</code></p>

<p>Is this what you are looking for?</p>

<pre><code>kubectl get nodes --selector=node-role.kubernetes.io/master -o jsonpath='{$.items[*].status.addresses[?(@.type=="InternalIP")].address}'
</code></pre>
