<p>I have deployed a mosquitto image in a pod in kubernetes with this dockerfile:</p>
<pre><code>FROM eclipse-mosquitto:1.6.7
</code></pre>
<p>I downloaded the image an added it to my cluster, using this yaml:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mosquitto-demo
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      bb: web
  template:
    metadata:
      labels:
        bb: web
    spec:
      containers:
      - name: bb-site
        image: mosquittotest:1.0
---
apiVersion: v1
kind: Service
metadata:
  name: mosquitto-entrypoint
  namespace: default
spec:
  type: NodePort
  selector:
    bb: web
  ports:
  - port: 8080
    targetPort: 8080
    nodePort: 30001
</code></pre>
<p>It is running correctly.</p>
<p>My question is: How can I know which IP is the one I should use t sub/pub, and which port?<br />
Do I just have to use the IP of the entrypoint service with the 8080 port?</p>
<p>I'm at a loss here.</p>

<p>Do you get an IP-address on the Service?</p>

<h2>Using ClusterIP</h2>

<p>To have an cluster interal IP, you should set <code>type=ClusterIP</code> on your service:</p>

<pre><code>spec:
  type: ClusterIP
</code></pre>

<p>Your clients route it requests to a DNS name for the service, depending on how your namespaces are setup. See <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">DNS for Services and Pods</a></p>

<h2>Using NodePort</h2>

<p>If you want to continue using type=NodePort, you can send request to the IP for any Node, but with the specific Node Port number.</p>
