kubernetes: unidirectional UDP traffic to a NodePort service is not handled properly
What happened:
I created a NodePort service listening on UDP to expose my syslog server.
When sending traffic to a Nodport on a node that doesn’t contain the pod I can see that the packet is being NATed and forwarded correctly through the tunnel to the node which runs this pod (I’m using Calico as CNI).
However, any consecutive packets on same connection/tuple are not being forwarded by the first node and gets dropped by it.
I did further research and found out that the pod needs to respond at least once on this connection in order for the first Node to allow more packets from the client on this connection to be forwarded to the pod.
looking at conntack:
conntrack -L -p UDP --dport 32063 udp 17 28 src=10.175.98.87 dst=10.175.3.82 sport=47909 dport=32063 [UNREPLIED] src=10.10.2.44 dst=10.10.1.1 sport=5514 dport=47909 mark=0 use=1
So it seems that as long as the [UNREPLIED] flag is set all packets from the client (except the first one which created this entry) are being dropped.
Syslog as is a unidirectional traffic, and server is not expected to reply with anything so this flow is broken.
What you expected to happen: All packets on same UDP connection hitting the NodePort service to be forwarded and NATed to the correct node and pod (not just the first packet)
How to reproduce it (as minimally and precisely as possible):
Send multiple UDP packets on same UDP connection to a NodePort service on a node that doesn’t have the endpoint pod running on it.
For example you can use nc to send multiple packets on same UDP connection:
nc -p <source_port> -u <destination_ip> <destination_port>
Environment:
-
Kubernetes version (use
kubectl version):Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T10:39:04Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T10:31:33Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"} -
Cloud provider or hardware configuration: it’s all on-prem
-
OS (e.g. from /etc/os-release):
NAME="Ubuntu" VERSION="18.04.1 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.1 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic -
Kernel (e.g.
uname -a):Linux k8s-master 4.15.0-34-generic #37-Ubuntu SMP Mon Aug 27 15:21:48 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
/sig network
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 33 (16 by maintainers)
@freehan - why did you close if it wasn’t fixed?
I just faced this issue and what worked for me was running
sudo iptables -P FORWARD ACCEPTon all cluster nodes.An unrelated comment: Kubeproxy and how it works by default which is using iptables is very problematic and this was the third time that I hit a problem related to kubeproxy and iptables and all of these 3 times it was a nightmare to pinpoint the real problem and even harder to find it on K8s github issues because of all of these stupid bots that are bombarding and closing issues without resolving them. This is exactly like sweeping the trash/problems under the carpet, please stop closing the issues without solving them.
We close issues if there is no response for 1 month.
open if needed
FWIW, we’re seeing the same issue when sending traces to Jaeger.
@avarf - I am sorry you are having a bad time with it. I want to help, but I’m not sure which issue you’re hitting at this point.
Sadly, there are a lot of different things that COULD be going wrong. I just ran my own attempt at a repro of this and I failed to repro the reported problem. It seems that either
ctstate NEWcovers “UNREPLIED” orctstate ESTABLISHEDcovers it. Either way, I do not see this problem being reproduced.Let’s take it apart a bit.
My (admittedly manual) testing agrees with this. Here’s what I did.
nc -l -u -p <port>)conntrack -D -p udp)iptables -t filter -D FORWARD -p udp -j ACCEPT)iptables -t filter -A FORWARD -p udp -m conntrack --ctstate NEW -j ACCEPT)So please tell me which problem we are facing for you? Even better, let’s open a NEW issue, without the baggage of this one. I need to see a full
iptables-saveas well as complete details about what’s happening.@skbly7: This request has been marked as needing help from a contributor.
Please ensure the request meets the requirements listed here.
If this request no longer meets these requirements, the label can be removed by commenting with the
/remove-helpcommand.In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
/assign @skbly7
The docs for NEW say “NEW The packet has started a new connection or otherwise associated with a connection which has not seen packets in both directions.” Sounds like that should match those packets. Has anyone tried adding it to the list of accepted states?