kubernetesautomationrancherapplication-lifecycle

How to automatically remove a Kubernetes pod when it does not receive TCP/UDP connections for a certain period of time?


Good morning. I need to know how can I automatically delete a pod that has not received TCP/UDP requests through the port through which its service is exposed. My intention is that if nobody accesses an application running in a pod for more than, for example, 3 hours, this pod will be automatically deleted to save unused resources, and if a new request is received, the pod will be automatically lifted again. Can anyone help me? Thank you.


Solution

  • Finally I will use KEDA (https://keda.sh/) to do scale-to-zero when prometheus doesn't detect TCP/UDP connections to a port. Thanks for your comments.