My legacy server listens on two TCP ports. I want to put livenessProbe and readinessProbe on two ports. For single port it looks like the following. How to do it for 2 ports ?
livenessProbe:
tcpSocket:
port: 15772
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 5
readinessProbe:
tcpSocket:
port: 15772
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 5
There are some paths to your goal. If you own the project running in the container, you can define a http endpoint like /heathz or /ready with your logic to achieve this. Otherwise, the project is a third-part one, you could write a shell to check ports like as follows:
healthcheck.sh
for port in 80 22
do nc -z localhost $port && echo "$port is up";
done
this shell will output (if 80 and 22 are listening):
80 is up
22 is up
and then, use exec probe:
livenessProbe:
exec:
command:
- /path/to/healthcheck.sh
...