cosmonic-labs/netreap

DNS

Closed this issue · 12 comments

The container does not resolve addresses via DNS:
curl: (6) Failed to resolve host: example.service.consul
But if you check the service in the consul, then it is registered in it
image

The ciliim parameters are as follows:
command: cilium-agent --kvstore consul --kvstore-opt consul.address=127.0.0.1:8500 -t geneve --enable-ipv6=false --prometheus-serve-addr="127.0.0.1:9962" --enable-l7-proxy=false

The policy config:

[
  {
    "labels": [
      {
        "key": "io.cosmonic.cilium_health"
      }
    ],
    "endpointSelector": {
      "matchLabels": {
        "reserved:health": ""
      }
    },
    "ingress": [
      {
        "fromEntities": ["remote-node", "host"]
      }
    ],
    "egress": [
      {
        "fromEntities": ["remote-node", "host"]
      }
    ]
  },
  {
    "endpointSelector": {},
    "labels": [
      {
        "key": "io.cosmonic.default_rule"
      }
    ],
    "ingress": [
      {
        "fromCIDRSet": [
          {
            "cidr": "0.0.0.0/0"
          }
        ]
      },
      {
        "fromEntities": ["host", "remote-node"]
      }
    ],
    "egress": [
      {
        "toEntity": ["host"],
        "toPorts": [
          {
            "ports": [
              {
                "port": "53",
                "protocol": "ANY"
              },
              {
                "port": "8600",
                "protocol": "ANY"
              }
            ]
          }
        ]
      },
      {
        "toCIDRSet": [
          {
            "cidr": "0.0.0.0/0"
          }
        ]
      }
    ]
  }
]

@deverton can you help?

The policy looks fine so my guess is this is more of a configuration issue with Nomad. Do you have Consul setup as the default resolver in resolv.conf or in the task definition?

Yes, I configured dnsmasq which manages dns. I did the setup according to the following instructions:
https://developer.hashicorp.com/consul/tutorials/networking/dns-forwarding
I can find it locally, but it doesn't work from the container

You'll probably need to get Hubble going so you can observe what the policy decisions are with the traffic from the container. I don't see anything here that would be a problem with netreap since it's just loading the policy in to the Cilium agents.

@deverton dns works fine for you?

@thomastaylor312 can you help?
when using the docker plugin there are no such problems.
Maybe there is some feature that is not indicated in the documentation?

To rule out any policy issues you can disable them cilium config PolicyEnforcement=never to do testing. In my setup I had to disable rpfilter to get traffic working net.ipv4.conf.default.rp_filter=0 and net.ipv4.conf.*.rp_filter=0 on Ubuntu 22.04.2.

@robloxrob
Netreap not labeling labels correctly! it does not remove the label "reserved:init"
image

I noticed that when you reboot, the shortcuts are not updated, but become "reserved:init"image

Great catch @Hanmask21!

@Hanmask21 reserved:init is a default label applied by Cilium, so I don't think that's an issue. Netreap should be reapplying the labels as soon as the job restarts if you've rebooted the Nomad node where it's running.

@protochron Labels by your logic should be applied in a new way on any restart, but this does not happen
Can you share access to your test bench with configured dns?

@protochron Problem solved.
The problem is solved by adding the following configurations to dnsmasq:

interface=docker0
bind-dynamic
listen-address=172.17.0.1