Extending the default NodePort range
You can increase or change the default range of ports that are used by NodePorts to allow specific ports to be opened for your application needs.
By default the service IP range is 31000-32000. This range contains 1000 ports, which means that you can create 1000 service resources only. If you need more services, or you need to expose specific ports that aren’t in this range for certain applications, then you need to change the range from the default.
Complete the following steps on each master node in your cluster:
-
Back up the
master.jsonfile.cp /etc/cfc/pods/master.json <back_up_location> -
From the backup location, edit the master.json file by adding a line after the
--servicecluster-ip-rangeparameter that contains--service-node-port-range=<start-port>-<endport>to suit the needs of your cluster. -
Add a comma to the end of the
--service-cluster-ip-rangeline. -
For high availability environments, you must update the
master.jsonfile on each master node one by one. Kubernetes services aren’t interrupted during the update process.
For example, to change the port range from 19000 to 22000, make the following updates:
-
Change
--service-cluster-ip-range=10.0.0.0/16to add a comma:--service-cluster-iprange=10.0.0.0/16, -
Add a line after the
--service-cluster-ip-rangeas follows:--service-node-portrange=19000-22000 -
Copy over the modified file to update the static pod manifest file:
cp /<back_up_location>/master.json /etc/cfc/pods/
When the manifest file updates, Kubelet restarts all the static pods, which include the kube-apiserver, kube-controller-manager, and kube-scheduler.