0
votes

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
What do you mean with ` python is also running because it could get stuck and the container could show that's everything fine.` ? About readiness and liveness the k8s documentation has good examples of how configure it. - Mr.KoopaKiller
I mean, does the liveness check if just if the pod is runnig or it check if python is running too? My leader told me that in some cases, the python can get stuck and the pod maybe running well and the liveness won't know if python is running or not. Is that possible or liveness would check the python and my pod? - Arthur Ávila

1 Answers

1
votes

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