Skip to content

NodeLocal DNS cache breaks connection tracking, conflicts with Calico #98758

Description

@fasaxc

What happened:

the node local DNS cache uses NOTRACK rules in iptables and these disable connection tracking. This is incompatible with Calico, which relies on connection tracking to implement its flow-based firewall. Since the DNS traffic gets hit with NOTRACK, the response packets are dropped because they're not part of a flow.

What you expected to happen:

DNS traffic conntracked as normal.

How to reproduce it (as minimally and precisely as possible):

This came from a user report, I think that what's needed is:

  • Install a system with Calico for CNI.
  • Add some network policy to a pod that allows egress DNS but disallows ingress.
  • DNS requests from the pod fail.

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): 1.17.4
  • Cloud provider or hardware configuration: Centos/Ubuntu
  • OS (e.g: cat /etc/os-release):
  • Kernel (e.g. uname -a):
  • Install tools:
  • Network plugin and version (if this is a network-related bug): Calico v3.14.1
  • Others:

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug.
    on Feb 4, 2021
  2. added
    needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.
    on Feb 4, 2021
  3. k8s-ci-robot commented on Feb 4, 2021

    @k8s-ci-robot
    Contributor

    @fasaxc: This issue is currently awaiting triage.

    If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

    The triage/accepted label can be added by org members by writing /triage accepted in a comment.

    Details

    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.

  4. added
    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.
    on Feb 4, 2021
  5. fasaxc commented on Feb 4, 2021

    @fasaxc
    ContributorAuthor

    /sig network

  6. added
    sig/networkCategorizes an issue or PR as relevant to SIG Network.
    and removed
    needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.
    on Feb 4, 2021
  7. thockin commented on Feb 4, 2021

    @thockin
    Member

    Can we get a bit more detail about which leg of DNS is being impacted? The rationale for NOTRACK is that connection-tracking + UDP + non-reused sockets == LOTS of conntrack records that serve literally no value but are all stuck waiting to expire => unhappy users.

  8. prameshj commented on Feb 4, 2021

    @prameshj
    Contributor

    Can we get a bit more detail about which leg of DNS is being impacted? The rationale for NOTRACK is that connection-tracking + UDP + non-reused sockets == LOTS of conntrack records that serve literally no value but are all stuck waiting to expire => unhappy users.

    Correct. NOTRACK was added as a feature to save on conntrack table entries and also avoid DNATs which had some race conditions leading to packet drops.
    I think a similar issue with NetworkPolicy was reported with NodeLocalDNS and we documented it in https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dns/nodelocaldns/README.md#network-policy-and-dns-connectivity

    Can we get more details on which part of the traffic was being dropped? is it the nodelocaldns to client pod response?

  9. pacoxu commented on Feb 5, 2021

    @pacoxu
    Member

    In #3795, users use calico GlobalNetworkPolicy and only projectcalico/calico#3795 (comment) without it.

  10. thockin commented on Feb 18, 2021

    @thockin
    Member

    What do we do with this issue?

  11. prameshj commented on Feb 18, 2021

    @prameshj
    Contributor

    We had this come up elsewhere and it was confirmed that the rule in https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dns/nodelocaldns/README.md#network-policy-and-dns-connectivity was working.

    Given that the node-local-dns behavior depends on allowing untracked connections, we would need this additional config.
    Can we check if that works in your setup too @fasaxc ?
    /assign @fasaxc

  12. thockin commented on Mar 4, 2021

    @thockin
    Member

    Ping @fasaxc

  13. fasaxc commented on Mar 9, 2021

    @fasaxc
    ContributorAuthor

    Sorry, I need to replicate the user's environment to get the next level of diags; haven't got around to doing that yet.

  14. thockin commented on Mar 18, 2021

    @thockin
    Member

    @prameshj Are we tracking this as a bug, as a feature request, or is it still needing triage?

  15. prameshj commented on Mar 18, 2021

    @prameshj
    Contributor

    Actually this is is Working as Intended.. so if configuring the rule documented in https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dns/nodelocaldns/README.md#network-policy-and-dns-connectivity works, then this can be closed, IMO.

  16. jayunit100 commented on Mar 22, 2021

    @jayunit100
    Member

    ... ok, so shall we close?

  17. prameshj commented on Mar 25, 2021

    @prameshj
    Contributor

    ok, let's close it. Please reopen if configuring the additional rule does not work.

    /close

  18. k8s-ci-robot commented on Mar 25, 2021

    @k8s-ci-robot
    Contributor

    @prameshj: Closing this issue.

    Details

    In response to this:

    ok, let's close it. Please reopen if configuring the additional rule does not work.

    /close

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

kind/bugCategorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/networkCategorizes an issue or PR as relevant to SIG Network.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions