kubernetes: Pod readiness probe cannot be directed at specific IP family
What happened:
When trying to deploy an IPv6-only application in a IPv4-first dual-stack cluster, I noticed that the following readiness probe will fail because it is trying to probe the first pod IP, which is IPv4.
readinessProbe:
failureThreshold: 30
httpGet:
path: /healthz/ready
port: 15021
scheme: HTTP
What you expected to happen:
It should be configurable which of the pod IPs should be probed
How to reproduce it (as minimally and precisely as possible):
Deploy application that does not listen for or accept IPv4 requests for readiness probe (==only IPv6) in IPv4-first DS cluster
Anything else we need to know?:
I guess I can work around it by adding the host: ::1 option to httpGet, though I ran into another problem with my application and could not verify this.
Environment:
- Kubernetes version (use
kubectl version): v1.20.4
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 5
- Comments: 45 (32 by maintainers)
Just for reference, in the meantime, there is a solution using the exec probe and curl …
From the dual-stack KEP:
A legacy application, possibly using some ancient 3rd party sw, may serve IPv4 only. Such an application can’t use probes on a cluster where
status.PodIPis IPv6, while it could ifstatus.PodIPis IPv4 (probably TCP probes).I think the reason that we haven’t seen issues about this is because cluster where
status.PodIPis IPv6 are still rare. But the shortage of IPv4 addresses (and the cost to cope with that problem) will soon enforce large clusters to havestatus.PodIPas IPv6, and not have IPv4 addresses on all PODs.And exec probes are not a solution, because they are too expensive. As an example a cluster with a background load of ~30% because of exec probes went down to ~3% when they were replaced with http probes. (I will try to get a reference).
Please note that the reverse problem is also true: in a cluster with base family IPv6, probes to (legacy) applications that only listens to IPv4 will fail.
I think that is a more common scenario and will hit us when base family IPv6 becomes common (because of the short-comings of IPv4).
@aojea Indeed it seems like a complex lift. As a workaround, I am using socat in a sidecar as follows:
This was discussed here https://github.com/kubernetes/enhancements/pull/1975 and the decision was to avoid complicating the kubelet probe logic until there was more evidence …
If host is empty it uses the PodIP, and in this case it seems to be the IPv4 https://github.com/kubernetes/kubernetes/blob/9e8506eb1f8724a2dda4fa8178528c8dce4f05b3/pkg/kubelet/prober/prober.go#L162-L167
IIRC kubelet is the one to execute the GET, so it will do it against the host localhost, not the pod localhost.
@danwinship @thockin @khenidak what do you think?
maybe add an IPFamily field to v1.Probe and if IPfamily is empty it uses whatever is in status.PodIP , otherwise choose the corresponding one in status.PodIPs