blog
  • Blogs
    • Medium Articles
      • Linux
        • 40 Powerful Linux Networking Commands You Must Know.
        • These (Linux) VI Editor Shortcuts You Must Know
        • Bash/Linux Interview Questions for DevOps Engineers
        • Page 1
      • Git
        • 40 Powerful Git Commands Every Developer Should Know
        • 10 Git Best Practices That Every Developer Must Know
      • DevOps/SRE Interview Questions and Answers
        • Top DevOps/SRE Interview Questions and Answers on AWS VPC
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Terraform Best Practices
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Kubernetes Best Practices
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Dockerfiles
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Grafana
      • Installation
        • Docker Installation on Ubuntu 20/22
        • Install WireGuard VPN on Docker Compose
        • Install Redis on Docker Compose
        • Gravitee Docker Compose
      • Kubernetes Series 2025
        • Understanding Kubernetes: Part 1 -Control Plane
        • Understanding Kubernetes: Part 2 -Worker Node
        • Understanding Kubernetes: Part 3 -Pod
        • Understanding Kubernetes: Part 4-ReplicaSets
        • Understanding Kubernetes: Part 5 -Deployment
        • Understanding Kubernetes: Part 6 -DaemonSets
        • Understanding Kubernetes: Part 7 -StatefulSet
        • Understanding Kubernetes: Part 8 -ConfigMap
        • Understanding Kubernetes: Part 9 -Kubernetes Secret
        • Understanding Kubernetes: Part 10 -StorageClass
        • Understanding Kubernetes: Part 11 -Persistent Volume (PV)
        • Understanding Kubernetes: Part 12 -Persistent Volume Claim (PVC)
        • Understanding Kubernetes: Part 13 -Services
        • Understanding Kubernetes: Part 14 -ClusterIP Service
        • Understanding Kubernetes: Part 15 -NodePort Service
        • Understanding Kubernetes: Part 16 -Load Balancer Service
        • Understanding Kubernetes: Part 17 -Ingress
        • Understanding Kubernetes: Part 18 -Ingress Controller
        • Understanding Kubernetes: Part 19 -Headless Service
        • Understanding Kubernetes: Part 20-Network Policy
        • Understanding Kubernetes: Part 21 -CNI
        • Understanding Kubernetes: Part 22 Kubernetes Resource Requests & Limits
        • Understanding Kubernetes: Part 23 Node Selector
        • Understanding Kubernetes: Part 24 Taints and Tolerations
        • Understanding Kubernetes: Part 25 Affinity and Anti-Affinity
        • Understanding Kubernetes: Part 26 Preemption and Priority
        • Understanding Kubernetes: Part 27 Role and RoleBinding
        • Understanding Kubernetes: Part 28 ClusterRole and ClusterRoleBinding
        • Understanding Kubernetes: Part 29 Service Account
        • Understanding Kubernetes: Part 30 Horizontal Pod Autoscaler (HPA)
        • Understanding Kubernetes: Part 31 Vertical Pod Autoscaler (VPA)
        • Understanding Kubernetes: Part 33 Startup Probe
        • Understanding Kubernetes: Part 34 Liveness Probe
        • Understanding Kubernetes: Part 35 Readiness Probe
        • Understanding Kubernetes: Part 36 Container Network Interface (CNI)
        • Understanding Kubernetes: Part 37 Container Runtime Interface (CRI)
        • Understanding Kubernetes: Part 38 Container Storage Interface (CSI)
      • Cloudflare
        • Cloudflare Tunnel for Secure HTTP Routing
      • Nginx
        • Nginx use cases that every engineer must know
Powered by GitBook
On this page
  1. Blogs
  2. Medium Articles
  3. Kubernetes Series 2025

Understanding Kubernetes: Part 34 Liveness Probe

PreviousUnderstanding Kubernetes: Part 33 Startup ProbeNextUnderstanding Kubernetes: Part 35 Readiness Probe

Last updated 3 months ago

📢 If you’ve been following our Kubernetes series 2025, welcome back! For new readers, check out

What is a Liveness Probe in Kubernetes?

A Liveness Probe in Kubernetes is a diagnostic tool used to check if a pod is still running properly. It helps Kubernetes determine whether a pod is healthy and should continue running. If a pod fails its liveness probe, Kubernetes will automatically restart it to restore functionality, ensuring high availability for the application.

For example:

Imagine you have a web application running in a pod, and sometimes the application can enter an unresponsive state due to high load or a bug. By configuring a liveness probe, Kubernetes can periodically check if the application is still responding. If the liveness probe fails, Kubernetes will restart the pod, thereby minimizing downtime and ensuring the application remains available.

Liveness Probe Capabilities:

  • Types of Checks: Liveness probes can use HTTP requests, TCP socket connections, or execute commands to check the health of a pod.

  • HTTP Check: Sends an HTTP request to a specified path and expects a successful response (e.g., 200 OK).

  • TCP Check: Tries to establish a TCP connection on a specified port. If successful, the pod is considered healthy.

  • Exec Check: Executes a command inside the container. If the command succeeds (exit code 0), the pod is considered healthy.

  • Failure Thresholds: You can configure how many consecutive failures must occur before the pod is considered unhealthy and is restarted.

  • Customizability: Liveness probes can be tuned with parameters like initialDelaySeconds, periodSeconds, timeoutSeconds, successThreshold, and failureThreshold.

In my previous role:

As a Senior DevOps Engineer, I implemented liveness probes for various microservices deployed on Kubernetes. For example, I configured a web application pod with an HTTP liveness probe to ensure that it was always responding to requests. When the application was not responding to HTTP requests, the probe would fail, and Kubernetes would automatically restart the pod, maintaining service availability. This helped us improve the overall reliability and uptime of our services.

Here’s a simple YAML for a Liveness Probe:

HTTP Liveness Probe:

apiVersion: v1
kind: Pod
metadata:
  name: web-app
spec:
  containers:
    - name: web-container
      image: web-app:latest
      livenessProbe:
        httpGet:
          path: /healthz
          port: 8080
        initialDelaySeconds: 10
        periodSeconds: 5
        timeoutSeconds: 2
        failureThreshold: 3

In this example:

  • The livenessProbe sends an HTTP GET request to the /healthz endpoint on port 8080 of the web-container.

  • The probe will start checking after a delay of 10 seconds (initialDelaySeconds), then continue every 5 seconds (periodSeconds).

  • If the probe takes longer than 2 seconds to respond, it will fail (timeoutSeconds).

  • If the probe fails 3 consecutive times (failureThreshold), Kubernetes will restart the pod.

TCP Liveness Probe:

apiVersion: v1
kind: Pod
metadata:
  name: database
spec:
  containers:
    - name: db-container
      image: db-image:latest
      livenessProbe:
        tcpSocket:
          port: 3306
        initialDelaySeconds: 5
        periodSeconds: 10

In this example:

  • The livenessProbe attempts to connect to the database on port 3306 using TCP.

  • It checks the pod’s health every 10 seconds, starting after an initial delay of 5 seconds.

Liveness probes are essential for ensuring that your application remains responsive and available. They automate the process of detecting and recovering from failures, reducing downtime and improving reliability in Kubernetes environments.

🚀 Ready to Master Kubernetes?

Take your Kubernetes journey to the next level with the Master Kubernetes: Zero to Hero course! 🌟 Whether you’re a beginner or aiming to sharpen your skills, this hands-on course covers:

✅ Kubernetes Basics — Grasp essential concepts like nodes, pods, and services. ✅ Advanced Scaling — Learn HPA, VPA, and resource optimization. ✅ Monitoring Tools — Master Prometheus, Grafana, and AlertManager. ✅ Real-World Scenarios — Build production-ready Kubernetes setups.

🔥 Flash Sale: Buy Kubernetes Course, Get Terraform FREE! Limited Time Offer!

Don’t miss your chance to become a Kubernetes expert! 💻✨

🚀 Master Terraform: Infrastructure as Code

Apply Code DEVOPS20 for 20% OFF!

🔥 Start Learning Now: [Join the Master Kubernetes Course + FREE Access to Terraform Course]()

🚀 Stay ahead in DevOps and SRE! 🔔 and never miss a beat on Kubernetes and more. 🌟

🔥 Start Learning Now:

https://cloudops0.gumroad.com/l/k8s
Subscribe now
Join the Master Terraform Course
Part 33 Startup Probe