Description
A readiness_probe checks whether a Pod can serve requests. If it fails, normal Service routing stops sending new traffic to that Pod. Liveness separately determines whether a container needs restarting.
Potential impact
A check that passes too easily can send requests to a Pod that is still starting or cannot serve. A check that fails too easily can take healthy Pods out of service.
Remediation
Use HTTP, TCP or exec to check actual serving ability. Tune the delay, period and thresholds for startup and temporary failures. Consider a startup probe for slow initialization and test that traffic reaches ready Pods during rollouts and recovery.
Examples
Both examples need nginx configured to serve /nginx_status on port 80. Use a maintained image for deployment.
Before
resource "kubernetes_pod" "pod" {
metadata {
name = "terraform-example"
}
spec {
container {
image = "nginx:1.7.9"
name = "example"
liveness_probe {
http_get {
path = "/nginx_status"
port = 80
}
}
}
}
}
After
resource "kubernetes_pod" "pod" {
metadata {
name = "terraform-example"
}
spec {
container {
image = "nginx:1.7.9"
name = "example"
readiness_probe {
http_get {
path = "/nginx_status"
port = 80
}
initial_delay_seconds = 10
}
liveness_probe {
http_get {
path = "/nginx_status"
port = 80
}
}
}
}
}
Both Pods use /nginx_status for liveness. The second also starts checking readiness at that path after 10 seconds.