0
0
Kubernetesdevops~30 mins

Why probes keep applications healthy in Kubernetes - See It in Action

Choose your learning style9 modes available
Why probes keep applications healthy
📖 Scenario: You are managing a Kubernetes cluster that runs a simple web application. To keep the application healthy and responsive, Kubernetes uses probes to check the application's status regularly.Probes help Kubernetes decide when to restart the application or stop sending traffic to it if it is not working properly.
🎯 Goal: Learn how to define and use Kubernetes probes (liveness and readiness) in a pod configuration to keep the application healthy.
📋 What You'll Learn
Create a basic pod configuration with a container running a simple web server
Add a liveness probe to check if the application is alive
Add a readiness probe to check if the application is ready to serve traffic
Print the final pod configuration YAML
💡 Why This Matters
🌍 Real World
Kubernetes probes help keep applications running smoothly by automatically detecting problems and restarting containers if needed.
💼 Career
Understanding probes is essential for DevOps engineers and site reliability engineers to maintain healthy and reliable applications in production.
Progress0 / 4 steps
1
Create a basic pod configuration
Create a variable called pod_config that holds a dictionary representing a Kubernetes pod configuration with these exact values: apiVersion set to v1, kind set to Pod, metadata with name set to myapp-pod, and spec with one container named myapp-container running the image nginx:1.21.
Kubernetes
Need a hint?

Use nested dictionaries and lists to build the pod configuration.

2
Add a liveness probe
Add a livenessProbe to the container inside pod_config. The probe should use an httpGet action with path set to /healthz, port set to 80, and initialDelaySeconds set to 5.
Kubernetes
Need a hint?

The livenessProbe is a dictionary inside the container dictionary.

3
Add a readiness probe
Add a readinessProbe to the container inside pod_config. The probe should use an httpGet action with path set to /ready, port set to 80, and initialDelaySeconds set to 3.
Kubernetes
Need a hint?

The readinessProbe is similar to the livenessProbe but with different path and delay.

4
Print the final pod configuration
Write a print statement to display the pod_config dictionary.
Kubernetes
Need a hint?

Use print(pod_config) to display the dictionary.