Self healing in Kubernetes - Can we regenerate the pod completely?

11/27/2018

I am new to Kubernetes.

  1. I have seen pod automaticaĺly restart in case of failure.

  2. When node failure happens, new pod regenerate to another node.

In both cases, What happens when pod gets failed in the middle of the process, (say: httpsession)? Can we provide the same session to the already logged in user. Please forgive if the question is irrelevant.

-- JibinNajeeb
docker
kubernetes
minikube

2 Answers

11/27/2018

Yes, the normal way to create pods is through one of the higher-level controllers like Deployments or StatefulSets. These will automatically detect if there are not the right number of pods and start replacements. As for showing the user the same log-in session, that's not usually related to the running pod, your login session on a website is usually stored in a cookie of some kind and references stuff in the database, not the web server.

-- coderanger
Source: StackOverflow

11/27/2018

Yes, you can use health-checks like readiness and liveness probes for your pod. No traffic will be routed to the pod till readiness check passes and pod will be restarted if liveness check fails. These checks can be added to your pod-spec.

And session management is not handled by k8s. It must be done by the application itself. Anyhow, If you want to persist some data you can use PV and PVC and bind the volume to your pod.

-- Ajay G
Source: StackOverflow