<p>I have this <code>docker-compose.yml</code> and Docker for Desktop Windows with a local kubernetes cluster (the default docker-desktop context) running:</p>

<pre><code>version: '3'
services:
  web:
    image: customnode
    ports:
    - "3000:3000"
    labels:
      kompose.service.type: nodeport

  datastore:
    image: custommongo
    ports:
    - "27017:27017"
</code></pre>

<p><code>docker-compose up -d</code> works perfectly and exposes my NodeJS on port <code>3000</code> on <code>127.0.0.1</code>.</p>

<p>I'm trying to migrate that the my k8s cluster, so following <a href="https://kompose.io/getting-started/" rel="nofollow noreferrer">https://kompose.io/getting-started/</a></p>

<p>Page above says "If you don’t already have a Kubernetes cluster running, minikube is the best way to get started"... I am already running the OOTB Docker for Desktop cluster so I assume I don't need minikube.</p>

<pre><code>kompose convert
INFO Kubernetes file "datastore-service.yaml" created
INFO Kubernetes file "web-service.yaml" created
INFO Kubernetes file "datastore-deployment.yaml" created
INFO Kubernetes file "web-deployment.yaml" created
</code></pre>

<p>Here are the web-deployment and web-service YAMLS:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.service.type: nodeport
    kompose.version: 1.16.0 (0c01309)
  creationTimestamp: null
  labels:
    io.kompose.service: web
  name: web
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: web
    spec:
      containers:
        image: customnode
        name: web
        ports:
        - containerPort: 3000
        resources: {}
      restartPolicy: Always
status: {}

apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.service.type: nodeport
    kompose.version: 1.16.0 (0c01309)
  creationTimestamp: null
  labels:
    io.kompose.service: web
  name: web
spec:
  ports:
  - name: "3000"
    port: 3000
    targetPort: 3000
  selector:
    io.kompose.service: web
  type: NodePort
status:
  loadBalancer: {}

</code></pre>

<p>Finally, running <code>kompose up</code>:</p>

<pre><code>kompose up
[36mINFO[0m We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.

INFO Deploying application in "default" namespace
INFO Successfully created Service: datastore
INFO Successfully created Service: web
INFO Successfully created Deployment: datastore
INFO Successfully created Deployment: web
</code></pre>

<p>Output of <code>kubectl get svc</code>:</p>

<pre><code>kubectl get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
datastore    ClusterIP   10.103.***.***   &lt;none&gt;        27017/TCP        76s
kubernetes   ClusterIP   10.96.0.1        &lt;none&gt;        443/TCP          23m
web          NodePort    10.106.***.***     &lt;none&gt;        3000:32033/TCP   76s
</code></pre>

<p>As you can see, no external IP as I'd expect. I'm sure this is a lack of knowledge on my part, rather than a bug, so what am I missing?</p>

A. Gardner
<p>Extenal IP is assigned only for <code>LoadBalancer</code> type service. A <code>LoadBalancer</code> controller must be installed on the cluster for <code>LoadBalancer</code> service to work. Else <code>LoadBalancer</code> service behaves exactly as a <code>NodePort</code> service. Most cloud providers have support for <code>LoadBalancer</code> services.</p>

<p>For <code>NodePort</code> type services, the service binds to a random port in node port range on all the nodes. In your case you can see, the service is bound to port 32033 - <code>3000:32033/TCP</code>. </p>

<p>The Node Port range is configured for as an argument to Kubernetes API server with the option <code>--service-node-port-range</code> (by default 30000-32767). When you create a NodePort type service, a random free port is picked from this range. If you want to choose a custom port, you can specify <code>nodePort</code> attribute in the <code>Port</code> object. </p>

<p>Eg:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.service.type: nodeport
    kompose.version: 1.16.0 (0c01309)
  creationTimestamp: null
  labels:
    io.kompose.service: web
  name: web
spec:
  ports:
  - name: "3000"
    port: 3000
    targetPort: 3000
    nodePort: 30002         ###### You can choose node port here if needed
  selector:
    io.kompose.service: web
  type: NodePort           ####### Change this line to LoadBalancer if you want an external IP
status:
  loadBalancer: {}
</code></pre>
