SlideShare ist ein Scribd-Unternehmen logo
1 von 13
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/

Weitere ähnliche Inhalte

Was ist angesagt?

Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
Volodymyr Shynkar
 

Was ist angesagt? (20)

DevOps with Kubernetes
DevOps with KubernetesDevOps with Kubernetes
DevOps with Kubernetes
 
Container orchestration overview
Container orchestration overviewContainer orchestration overview
Container orchestration overview
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker Compose
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshop
 
Evolution of containers to kubernetes
Evolution of containers to kubernetesEvolution of containers to kubernetes
Evolution of containers to kubernetes
 
Best Practices with Azure Kubernetes Services
Best Practices with Azure Kubernetes ServicesBest Practices with Azure Kubernetes Services
Best Practices with Azure Kubernetes Services
 
Deep dive into Kubernetes Networking
Deep dive into Kubernetes NetworkingDeep dive into Kubernetes Networking
Deep dive into Kubernetes Networking
 
Amazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for KubernetesAmazon EKS - Elastic Container Service for Kubernetes
Amazon EKS - Elastic Container Service for Kubernetes
 
Best Practices for Middleware and Integration Architecture Modernization with...
Best Practices for Middleware and Integration Architecture Modernization with...Best Practices for Middleware and Integration Architecture Modernization with...
Best Practices for Middleware and Integration Architecture Modernization with...
 
Intro to kubernetes
Intro to kubernetesIntro to kubernetes
Intro to kubernetes
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes Networking
 
Containers Anywhere with OpenShift by Red Hat
Containers Anywhere with OpenShift by Red HatContainers Anywhere with OpenShift by Red Hat
Containers Anywhere with OpenShift by Red Hat
 
Introduction of Kubernetes - Trang Nguyen
Introduction of Kubernetes - Trang NguyenIntroduction of Kubernetes - Trang Nguyen
Introduction of Kubernetes - Trang Nguyen
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
 
Autoscaling Kubernetes
Autoscaling KubernetesAutoscaling Kubernetes
Autoscaling Kubernetes
 
Docker Swarm Introduction
Docker Swarm IntroductionDocker Swarm Introduction
Docker Swarm Introduction
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
 

Ähnlich wie Kubernetes Probes (Liveness, Readyness, Startup) Introduction

Easy distributed load test with Tsung
Easy distributed load test with TsungEasy distributed load test with Tsung
Easy distributed load test with Tsung
Ngoc Dao
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server Internals
Praveen Gollakota
 
Docker at DevTable
Docker at DevTableDocker at DevTable
Docker at DevTable
Docker, Inc.
 

Ähnlich wie Kubernetes Probes (Liveness, Readyness, Startup) Introduction (20)

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

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

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/