Description
A readinessProbe tells Kubernetes when a container can handle requests. Ordinary Services stop routing traffic to an unready Pod, but direct Pod connections remain possible. A failed liveness check can trigger a restart.
Potential impact
Without a readiness check, requests can reach a starting container and fail during a rollout or restart.
Remediation
- Choose an HTTP, TCP, command, or other supported check that succeeds when the application can serve requests. Use TCP only when accepting a connection is a sufficient readiness signal.
- Set the initial delay and check interval to match startup behavior. Test Service traffic during a rollout and when the application becomes unready.
Examples
Use an available image that listens on port 8080. Adjust the example probe timings to your application.
Before
yaml
apiVersion: v1
kind: Pod
metadata:
name: goproxy
spec:
containers:
- name: goproxy
image: k8s.gcr.io/goproxy:0.1
ports:
- containerPort: 8080
livenessProbe:
tcpSocket:
port: 8080
After
yaml
apiVersion: v1
kind: Pod
metadata:
name: goproxy
spec:
containers:
- name: goproxy
image: k8s.gcr.io/goproxy:0.1
ports:
- containerPort: 8080
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 8080
Explanation:
- Before: Only
livenessProbechecks port 8080. - After:
readinessProbealso tests the port. A successful connection marks the container ready.