kompose not exposing NodePort - Docker for Desktop Windows kompose not exposing NodePort - Docker for Desktop Windows kubernetes kubernetes

kompose not exposing NodePort - Docker for Desktop Windows


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

For NodePort 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 - 3000:32033/TCP.

The Node Port range is configured for as an argument to Kubernetes API server with the option --service-node-port-range (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 nodePort attribute in the Port object.

Eg:

apiVersion: v1kind: Servicemetadata:  annotations:    kompose.cmd: kompose convert    kompose.service.type: nodeport    kompose.version: 1.16.0 (0c01309)  creationTimestamp: null  labels:    io.kompose.service: web  name: webspec:  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 IPstatus:  loadBalancer: {}