calico: HostPort of pod/container can't access from other nodes in eBPF mode
After enabling eBPF mode of calico, then I created a pod which has a hostPort setting, what I expected is the clients from every node and outside of cluster can access hostIP:hostPort, but the result is: it can be accessed only from the host where the pod is located, but can’t be accessed from other nodes or outside of cluster.
Expected Behavior
the clients from every node and outside of cluster can access hostIP:hostPort
Current Behavior
it can be accessed only from the host where the pod is located. it can’t be accessed from other nodes or outside of cluster. when I use “curl hostIP:hostPort”, it just hang.
Possible Solution
Steps to Reproduce (for bugs)
- stop kube-proxy on every nodes
- restart linux
- enable ebpf dataplane:
calicoctl patch felixconfiguration default --patch='{"spec": {"bpfEnabled": true}}' - recreate all calico pods and test pods.
Context
“curl PodIP:containerPort” is always successful from other nodes.
Your Environment
- Calico version: v3.23.3
- Orchestrator version: kubernetes 1.23.9
- Operating System and version: CentOS 8.2
- Link to your project (optional):
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 25 (14 by maintainers)
See kubernetes/kops#14685 for removing this workaround in kOps.
As it stand now,
FELIX_BPFHostConntrackBypasssetting does not affect the hostPort behaviour, i.e. setting it to true or false won’t matter to the hostPort traffic. In both cases, hostPort should work fine.@mazdakn could you backport it to 3.24 too? 🙏
The issue is fixed and should work as expected in v3.25
Here’s the output from iptables-save -c run on a machine hosting at least one pod using a host port. In this case, look for TCP port 3001, used by a pod with IP address 100.103.226.208.
"iptables-save -c" output
This machine is running Kubernetes 1.24.4 and Calico 3.23.3 atop Flatcar Container Linux 3277.1.2, reporting Linux kernel version 5.15.63.
@gongzh the solution is to set
FELIX_BPFHostConntrackBypass=falseYou have to do it as an env variable for now as it is missing in the felix configuration resource. Will be fixed.