How can i change a service running on one port number, now i want to run another service on same old port number

1/29/2019

I am using a deployment yaml file ex:nginx which i am using port 30080. Now i wrote another deployment yaml file but i want to use port number 30080.

The Service "web" is invalid: spec.ports[0].nodePort: Invalid value: 30080: >provided port is already allocated

How can i use the port number 30080 for my new deployment web.yaml file. 1)Deleted the nginx pod running. 2)Deleted nginx deployment running.

But how can i free up the port number 30080.

i checked the port number:

sudo iptables-save | grep 30080

-A KUBE-EXTERNAL-SERVICES -p tcp -m comment --comment "default/nginx-service: has no endpoints" -m addrtype --dst-type LOCAL -m tcp --dport 30080 -j REJECT --reject-with icmp-
port-unreachable 
-- Rocky Hai
kubernetes
port
yaml

1 Answer

1/30/2019

i deleted deployment and pod. But i forgot that service is running after deleting nginx service i am able to reuse the port number 30080 for other deployment.

socket.error: [Errno 48] Address already in use

this question also helped me but it points to killing that process, here the process running is kube-proxy.

sudo lsof -i:30080

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME kube-prox 3320 root 8u IPv6 40388 0t0 TCP *:30080 (LISTEN)

which i cant delete.It might create issue deleting kube-prox

Please let me know if this was the right approach or not.

-- Rocky Hai
Source: StackOverflow