1
we are currently setting up a Kubernetes Cluster. Kubernetes starts up at server boot normally and after a while, after the program "kubelet" has fully loaded its components, the network port 30000 opens up. Takes up to 20 seconds.
Only when 30000 is open, I can run a port forwarding command. Not earlier.
I tested the command manually, no problems here. Working like a charm.
But since I want that port forwarding command to run automatically (and with root privileges), I am now wondering how to archieve this.
Somehow putting the command into a script, somehow running that script at boot time, somehow waiting for port 30000 to show up...
I know of course how to check manually, if port 30000 is open (netstat, telnet, lsof... see here https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/). But how can I do that programmatically? Sorry, I have never written Linux shell scripts before.
Btw: I am using Ubuntu Server 18.04 as virtual machine for this.
Any help is appreciated. Thanks! Greetings!
Could you run a script at bootup that checks whether the port is open. If open, run command. If not, check again? I mean like a loop to check the port and if the condition is met, then run the command and exit loop? – padawan_IT – 2019-05-23T09:15:14.333
@padawan_IT I know that. But how can it be run on boot time? – xola – 2019-06-05T08:07:16.020
You could use the cronjob: https://help.ubuntu.com/community/CronHowto
@Reboot is the option you are looking for.