How to increase the range of ports available to services in kubernetes

7/25/2017

I want to create a loadBalancer service on kubernetes that exposes a large range of ports. As you can't do that on kubernetes yet (https://github.com/kubernetes/kubernetes/issues/23864).

I have manually entered a range of port by having a yaml file in the following format:

apiVersion: v1
kind: Service
metadata: 
  name: service
spec:
  ports:
  - name: port10000
  port: 10000
  protocol: UDP
    .
    .
    .
  - name: port40000
  port: 40000
  protocol: UDP
  selector: 
    app: app-label
  type: LoadBalancer    

I get the following error:

Error from server (InternalError): error when creating "service-udp.yml": Internal error occurred: failed to allocate a nodePort: range is full

Is it possible to increase the range of ports available for a service? And if so, how?

-- Sebastien
kubernetes
load-balancing
ports

1 Answer

7/25/2017

This is controlled by the --service-node-port-range portRange argument to kube-apiserver - the way to change that depends on your environment.

Keep in mind that nodePorts are meant to be used by load balancers as building blocks. So what you are trying to do is most likely not the best practice.

Hope this helps..

-- Janos Lenart
Source: StackOverflow