Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes , liveness probe is failing but pod in Running state

Tags:

kubernetes

I'm trying to do a blue green deployment with kubernetes , I have followed it , https://www.ianlewis.org/en/bluegreen-deployments-kubernetes , that is ok. I have added a liveness probe to execute a healthcheck ,

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: flask-1.3
spec:
  replicas: 2
  template:
    metadata:
      labels:
        name: app
        version: "1.3"
    spec:
      containers: 
        - name: appflask
          image: 192.168.99.100:5000/fapp:1.2
          livenessProbe:
            httpGet:
             path: /index2
             port: 5000
            failureThreshold: 1
            periodSeconds: 1
            initialDelaySeconds: 1
          ports:
            - name: http
              containerPort: 5000

the path "index2" doesnt exist , I want to test a failed deployment. the problem is when I execute:

 kubectl get pods -o wide

for some seconds one of the pods is in state "RUNNING"

NAME                         READY   STATUS             RESTARTS   AGE     IP             NODE    NOMINATED NODE   READINESS GATES

flask-1.3-6c644b8648-878qz   0/1     CrashLoopBackOff   6          6m19s   10.244.1.250   node    <none>           <none>
flask-1.3-6c644b8648-t6qhv   0/1     CrashLoopBackOff   7          6m19s   10.244.2.230   nod2e   <none>           <none>

after some seconds one pod is RUNNING when live is failing always:

NAME                         READY   STATUS             RESTARTS   AGE 

    IP             NODE    NOMINATED NODE   READINESS GATES

   flask-1.3-6c644b8648-878qz   1/1     Running            7          6m20s   10.244.1.250   node    <none>           <none>
    flask-1.3-6c644b8648-t6qhv   0/1     CrashLoopBackOff   7          6m20s   10.244.2.230   nod2e   <none>           <none>

And after RUNNING it back to CrashLoopBackOff, the question is , why for some seconds it keeps RUNNING if the livenesprobe go to fail always?

thanks in advance

like image 753
Esteban Ziths Avatar asked Jan 04 '19 13:01

Esteban Ziths


1 Answers

You should be looking at Readiness probe instead, or both of them.

Readiness and liveness probes can be used in parallel for the same container. Using both can ensure that traffic does not reach a container that is not ready for it, and that containers are restarted when they fail.

Liveness probe checks if your application is in a healthy state in your already running pod.

Readiness probe will actually check if your pod is ready to receive traffic. Thus, if there is no /index2 endpoint, it will never appear as Running

like image 123
edbighead Avatar answered Oct 24 '22 00:10

edbighead