Port Range Configuration
The following methods are common practices and may vary depending on the system environment. If they do not work as expected, please refer to relevant documentation and troubleshooting solutions.
Docker Deployment
sudo nano /etc/sysctl.conf
- Add the following content to specify
ip_local_port_range
:
net.ipv4.ip_local_port_range = 20000 50000
- Run
sudo sysctl -p
to apply the changes - Restart Docker service
K3s Deployment
sudo nano /etc/systemd/system/k3s.service
- Edit the
ExecStart
in the following settings to specifyservice-node-port-range
ExecStart=/usr/local/bin/k3s \
server \
--kube-apiserver-arg service-node-port-range=20000-50000
sudo systemctl daemon-reload
sudo systemctl restart k3s
K8s Deployment
The default range is 30000-32767
. If adjustments are needed, please refer to the following:
- Run
sudo vim /etc/kubernetes/manifests/kube-apiserver.yaml
. - Add
--service-node-port-range=<new-range>
inspec.containers.command
. - For example,
--service-node-port-range=30000-40000
. - If there are multiple master nodes, please ensure that all master nodes are modified.
- If deployed as a binary, modify the
kube-apiserver
configuration file, use the same parameters as above, and restart the service.
Docker Swarm Deployment:
We have not tried it yet. If anyone has succeeded, please feel free to submit a PR to add it.