SlideShare a Scribd company logo
Kubernetes Learning: Probes
Configure Liveness, Readiness, Startup
Probe
Liveness Probes
● Used by Kubelet
● To know when to restart the container
● Catching a Deadlock
● Despite App’s Bugs
Readiness Probe
● Used by Kubelet
● To know when a container is ready to start accepting traffic
● When all of its containers are ready
● Control which Pods are used as backends for Services
Startup Probes
● To know when a container application has started
● It disables liveness and readiness checks until it succeeds
● Can be used to adopt liveness checks on slow starting containers
Defining Liveness Probe (Using
Command)
● Create The Pod
kubectl apply -f https://k8s.io/examples/pods/probe/exec-
liveness.yaml
● Check the Pod, the Pod will be live for a 30 seconds
before it will be killed, and restarted
kubectl get pod liveness-exec
● The periodSeconds field specifies that the kubelet
should perform a liveness probe every 5 seconds
● The initialDelaySeconds field tells the kubelet that it
should wait 5 second before performing the first probe
● To perform a probe, the kubelet executes the
command cat /tmp/healthy in the target container. If
the command succeeds, it returns 0, and the kubelet
considers the container to be alive and healthy. If the
command returns a non-zero value, the kubelet kills
the container and restarts it.
● Describe the Pod, to Check it lifecycle
kubectl describe pod liveness-exec
Defining Liveness Probe (Using
httpGet)
● Example http Endpoint
http.HandleFunc("/healthz", func(w http.ResponseWriter, r
*http.Request) {
duration := time.Now().Sub(started)
if duration.Seconds() > 10 {
w.WriteHeader(500)
w.Write([]byte(fmt.Sprintf("error: %v", duration.Seconds())))
} else {
w.WriteHeader(200)
w.Write([]byte("ok"))
}
})
Defining Liveness Probe (Using TCP)
Using Named Container’s Port
Protect slow starting containers with startup probes
● Used commonly with legacy app.
● That might require an additional startup time on
their first initialization.
● The trick is to set up a startup probe with the
same command, HTTP or TCP check
● Once the startup probe has succeeded once, the
liveness probe takes over to provide a fast
response to container deadlocks.
Define readiness probes
● an application might need to load large data or
configuration files during startup, or depend on
external services after startup
● Readiness probes are configured similarly to
liveness probes.
● Configuration for HTTP and TCP readiness
probes also remains identical to liveness probes.
● 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.
Configure Probes (1)
Probes have a number of fields that you can use to more precisely control the behavior of liveness and
readiness checks:
● initialDelaySeconds: Number of seconds after the container has started before liveness or readiness
probes are initiated. Defaults to 0 seconds. Minimum value is 0.
● periodSeconds: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is
1.
● timeoutSeconds: Number of seconds after which the probe times out. Defaults to 1 second. Minimum
value is 1.
● successThreshold: Minimum consecutive successes for the probe to be considered successful after
having failed. Defaults to 1. Must be 1 for liveness. Minimum value is 1.
● failureThreshold: When a Pod starts and the probe fails, Kubernetes will try failureThreshold times
before giving up. Giving up in case of liveness probe means restarting the container. In case of
readiness probe the Pod will be marked Unready. Defaults to 3. Minimum value is 1.
Configure Probes (2)
HTTP probes have additional fields that can be set on httpGet:
● host: Host name to connect to, defaults to the pod IP. You probably want to set “Host” in httpHeaders
instead.
● scheme: Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP.
● path: Path to access on the HTTP server.
● httpHeaders: Custom headers to set in the request. HTTP allows repeated headers.
● port: Name or number of the port to access on the container. Number must be in the range 1 to 65535.
Thank You
© 2020 , By Akhmad Zaki Al-Safi
Summaried from: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/

More Related Content

PPTX
Kubernetes PPT.pptx
PPTX
Everything You Need To Know About Persistent Storage in Kubernetes
PDF
Introduction to Kubernetes Workshop
PDF
Kubernetes Basics
PDF
Getting Started with Kubernetes
PDF
An Introduction to Kubernetes
PDF
Kubernetes Application Deployment with Helm - A beginner Guide!
PDF
Efficient Kubernetes scaling using Karpenter
Kubernetes PPT.pptx
Everything You Need To Know About Persistent Storage in Kubernetes
Introduction to Kubernetes Workshop
Kubernetes Basics
Getting Started with Kubernetes
An Introduction to Kubernetes
Kubernetes Application Deployment with Helm - A beginner Guide!
Efficient Kubernetes scaling using Karpenter

What's hot (20)

PDF
Terraform -- Infrastructure as Code
PDF
Kubernetes or OpenShift - choosing your container platform for Dev and Ops
PDF
Introduction to kubernetes
PDF
Kubernetes 101
PDF
Event driven autoscaling with KEDA
PPTX
Azure kubernetes service (aks)
PPSX
Microservices Architecture - Cloud Native Apps
PDF
Open shift 4 infra deep dive
PDF
Deep dive into Kubernetes Networking
PDF
Kubernetes Networking
PDF
Hands-On Introduction to Kubernetes at LISA17
PPTX
Introduction to the Container Network Interface (CNI)
PPTX
Kubernetes
PDF
Kubernetes
PDF
Kubernetes security
PDF
Persistent Storage with Containers with Kubernetes & OpenShift
PDF
Kubernetes dealing with storage and persistence
PDF
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
PPTX
DevOps with Kubernetes
PDF
Introduction to kubernetes
Terraform -- Infrastructure as Code
Kubernetes or OpenShift - choosing your container platform for Dev and Ops
Introduction to kubernetes
Kubernetes 101
Event driven autoscaling with KEDA
Azure kubernetes service (aks)
Microservices Architecture - Cloud Native Apps
Open shift 4 infra deep dive
Deep dive into Kubernetes Networking
Kubernetes Networking
Hands-On Introduction to Kubernetes at LISA17
Introduction to the Container Network Interface (CNI)
Kubernetes
Kubernetes
Kubernetes security
Persistent Storage with Containers with Kubernetes & OpenShift
Kubernetes dealing with storage and persistence
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
DevOps with Kubernetes
Introduction to kubernetes
Ad

Similar to Kubernetes Probes (Liveness, Readyness, Startup) Introduction (20)

PDF
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
PDF
Introduction to ZooKeeper - TriHUG May 22, 2012
PDF
Proactive monitoring with Monit
PDF
Building resilient applications
PDF
Go 1.8 'new' networking features
PDF
On the benchmark of Chainer
PPTX
Kubernetes Introduction
PDF
Jetty Continuation - 이상민
ODP
Easy distributed load test with Tsung
PPTX
K8s@Pollfish - Can you run a monolith on k8s?
PDF
Scaling Microservices with Kubernetes
PPTX
Process scheduling
PDF
Tornado Web Server Internals
PPTX
Docker at DevTable
PPTX
Docker at DevTable
PPTX
.NET Multithreading/Multitasking
PDF
FreeRTOS Slides annotations.pdf
PDF
Demystifying kubernetes
PPTX
PPTX
Oracle real application clusters system tests with demo
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
Introduction to ZooKeeper - TriHUG May 22, 2012
Proactive monitoring with Monit
Building resilient applications
Go 1.8 'new' networking features
On the benchmark of Chainer
Kubernetes Introduction
Jetty Continuation - 이상민
Easy distributed load test with Tsung
K8s@Pollfish - Can you run a monolith on k8s?
Scaling Microservices with Kubernetes
Process scheduling
Tornado Web Server Internals
Docker at DevTable
Docker at DevTable
.NET Multithreading/Multitasking
FreeRTOS Slides annotations.pdf
Demystifying kubernetes
Oracle real application clusters system tests with demo
Ad

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
KodekX | Application Modernization Development
PPT
Teaching material agriculture food technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
sap open course for s4hana steps from ECC to s4
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Big Data Technologies - Introduction.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Weekly Chronicles - August'25 Week I
KodekX | Application Modernization Development
Teaching material agriculture food technology
Network Security Unit 5.pdf for BCA BBA.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Advanced methodologies resolving dimensionality complications for autism neur...
Spectral efficient network and resource selection model in 5G networks
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Chapter 3 Spatial Domain Image Processing.pdf
Understanding_Digital_Forensics_Presentation.pptx

Kubernetes Probes (Liveness, Readyness, Startup) Introduction

  • 1. Kubernetes Learning: Probes Configure Liveness, Readiness, Startup Probe
  • 2. Liveness Probes ● Used by Kubelet ● To know when to restart the container ● Catching a Deadlock ● Despite App’s Bugs
  • 3. Readiness Probe ● Used by Kubelet ● To know when a container is ready to start accepting traffic ● When all of its containers are ready ● Control which Pods are used as backends for Services
  • 4. Startup Probes ● To know when a container application has started ● It disables liveness and readiness checks until it succeeds ● Can be used to adopt liveness checks on slow starting containers
  • 5. Defining Liveness Probe (Using Command) ● Create The Pod kubectl apply -f https://k8s.io/examples/pods/probe/exec- liveness.yaml ● Check the Pod, the Pod will be live for a 30 seconds before it will be killed, and restarted kubectl get pod liveness-exec ● The periodSeconds field specifies that the kubelet should perform a liveness probe every 5 seconds ● The initialDelaySeconds field tells the kubelet that it should wait 5 second before performing the first probe ● To perform a probe, the kubelet executes the command cat /tmp/healthy in the target container. If the command succeeds, it returns 0, and the kubelet considers the container to be alive and healthy. If the command returns a non-zero value, the kubelet kills the container and restarts it. ● Describe the Pod, to Check it lifecycle kubectl describe pod liveness-exec
  • 6. Defining Liveness Probe (Using httpGet) ● Example http Endpoint http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { duration := time.Now().Sub(started) if duration.Seconds() > 10 { w.WriteHeader(500) w.Write([]byte(fmt.Sprintf("error: %v", duration.Seconds()))) } else { w.WriteHeader(200) w.Write([]byte("ok")) } })
  • 9. Protect slow starting containers with startup probes ● Used commonly with legacy app. ● That might require an additional startup time on their first initialization. ● The trick is to set up a startup probe with the same command, HTTP or TCP check ● Once the startup probe has succeeded once, the liveness probe takes over to provide a fast response to container deadlocks.
  • 10. Define readiness probes ● an application might need to load large data or configuration files during startup, or depend on external services after startup ● Readiness probes are configured similarly to liveness probes. ● Configuration for HTTP and TCP readiness probes also remains identical to liveness probes. ● 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.
  • 11. Configure Probes (1) Probes have a number of fields that you can use to more precisely control the behavior of liveness and readiness checks: ● initialDelaySeconds: Number of seconds after the container has started before liveness or readiness probes are initiated. Defaults to 0 seconds. Minimum value is 0. ● periodSeconds: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. ● timeoutSeconds: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. ● successThreshold: Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness. Minimum value is 1. ● failureThreshold: When a Pod starts and the probe fails, Kubernetes will try failureThreshold times before giving up. Giving up in case of liveness probe means restarting the container. In case of readiness probe the Pod will be marked Unready. Defaults to 3. Minimum value is 1.
  • 12. Configure Probes (2) HTTP probes have additional fields that can be set on httpGet: ● host: Host name to connect to, defaults to the pod IP. You probably want to set “Host” in httpHeaders instead. ● scheme: Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP. ● path: Path to access on the HTTP server. ● httpHeaders: Custom headers to set in the request. HTTP allows repeated headers. ● port: Name or number of the port to access on the container. Number must be in the range 1 to 65535.
  • 13. Thank You © 2020 , By Akhmad Zaki Al-Safi Summaried from: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/