<p>In <a href="https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-setting-up-health-checks-with-readiness-and-liveness-probes" rel="nofollow noreferrer">Google Cloud blog</a> they say that if Readiness probe fails, then traffic will not be routed to a <strong>pod</strong>. And if Liveliness probe fails, a <strong>pod</strong> will be restarted.</p>
<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">Kubernetes docs</a> they say that the kubelet uses Liveness probes to know if a <strong>container</strong> needs to be restarted. And Readiness probes are used to check if a <strong>container</strong> is ready to start accepting requests from clients.</p>
<p>My current understanding is that a pod is considered Ready and Alive when <strong>all</strong> of its containers are ready. This in turn implies that if 1 out of 3 containers in a pod fails, then the entire pod will be considered as failed (not Ready / not Alive). And if 1 out of 3 containers was restarted, then it means that the entire pod was restarted. Is this correct?</p>

kamokoba
<p>A <code>Pod</code> is ready only when all of its containers are ready.
When a Pod is ready, it should be added to the load balancing pools of all matching Services because it means that this Pod is able to serve requests.<br />
As you can see in the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes" rel="nofollow noreferrer">Readiness Probe documentation</a>:</p>
<blockquote>
<p>The kubelet uses readiness probes to know when a container is ready to start accepting traffic.</p>
</blockquote>
<p>Using <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes" rel="nofollow noreferrer"><strong>readiness probe</strong></a> can ensure that traffic does not reach a container that is not ready for it.<br />
Using <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-tcp-liveness-probe" rel="nofollow noreferrer"><strong>liveness probe</strong></a> can ensure that container is restarted when it fail ( the kubelet will kill and restart only the specific container).</p>
<p>Additionally, to answer your last question, I will use an example:</p>
<blockquote>
<p>And if 1 out of 3 containers was restarted, then it means that the entire pod was restarted. Is this correct?</p>
</blockquote>
<p>Let's have a simple <code>Pod</code> manifest file with <code>livenessProbe</code> for one container that always fails:</p>
<pre><code>---
# web-app.yml
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: web-app
  name: web-app
spec:
  containers:
  - image: nginx
    name: web

  - image: redis
    name: failed-container
    livenessProbe:
      httpGet:
        path: /healthz # I don't have this endpoint configured so it will always be failed.
        port: 8080
</code></pre>
<p>After creating <code>web-app</code> <code>Pod</code> and waiting some time, we can check how the <code>livenessProbe</code> works:</p>
<pre><code>$ kubectl describe pod web-app
Name:         web-app
Namespace:    default
Containers:
  web:
    ...
    State:          Running
      Started:      Tue, 09 Mar 2021 09:56:59 +0000
    Ready:          True
    Restart Count:  0
    ...
  failed-container:
    ...
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Completed
      Exit Code:    0
    Ready:          False
    Restart Count:  7
    ...
Events:
  Type     Reason     Age                   From               Message
  ----     ------     ----                  ----               -------
  ...
  Normal   Killing    9m40s (x2 over 10m)   kubelet            Container failed-container failed liveness probe, will be restarted
  ...
</code></pre>
<p>As you can see, only the <code>failed-container</code> container was restarted (<code>Restart Count:  7</code>).</p>
<p>More information can be found in the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">Liveness, Readiness and Startup Probes documentation</a>.</p>
