Does Kubernetes Liveness and Readiness check if python is running?

2.8k views Asked by At

I've got a simple question but I can't find out the right answer.

I have a couple of pods runnig my applications in python in kubernetes. I didn't implement liveness and readiness yet. When I was talking to my leader, he told me that I had to create the liveness and readiness for check and restart my pods when necessary and I had to find a way to make the liveness and readiness check if the python is also running because it could get stuck and the container could show that's everything fine.

I'v got confused because for my liveness and readiness would do this. I must create it using command, as this microservices doesn't have endpoint or healthcheck as they are just workers.

Any clue for how can I do that? Or a good answer that can explain that liveness and readiness check whether the python is running or not.

Thanks a lot!

1

There are 1 answers

3
islamhamdi On

Readiness won't restart your pod, it'll just make your worker not reachable through a load balancer/service, Liveness will do restart if the condition failed. You don't need to have liveness run through an endpoint, you can make sure that it's just reachable:

        livenessProbe:
          failureThreshold: 3
          initialDelaySeconds: 30
          periodSeconds: 20
          successThreshold: 1
          tcpSocket:
            port: <port-number>
          timeoutSeconds: 5

You can expose a port on the running python worker and just make sure that it's reachable, otherwise, think logically about when you do want to restart the pod? what do you mean by it could get stuck