calico: Failed to connect to kube-dns after setting up calico cni

Expected Behavior

Should be able to connect with kube-dns ip from any of the pods

Current Behavior

Fails to connect with kube-dns service ip from within the pod and because of this any operation that needs dns resolution fails inside any of the scheduled pods in the cluster.

Possible Solution

Steps to Reproduce (for bugs)

Context

I’ve setup kubernetes v1.29 using kubeadm and using tiegra operator for setting up the calico version v3.27.3. All of the calico-nodes are running fine without any restarts and I don’t see any obvious errors. Installation config

apiVersion: operator.tigera.io/v1
kind: Installation
metadata:
  name: default
spec:
  # Configures Calico networking.
  logging:
    cni:
     logSeverity: Debug
  serviceCIDRs:
    - "172.31.0.0/16"
  calicoNetwork:
    # Note: The ipPools section cannot be modified post-install.
    bgp: Disabled
    ipPools:
    - blockSize: 26
      cidr: 192.168.0.0/16
      encapsulation: VXLANCrossSubnet
      natOutgoing: Enabled
      nodeSelector: all()

---
I also tried by removing `serviceCIDRs` from the `Installation` manifest because it's defined in kubadm config too `ClusterConfiguration`,  but didn't work for me
# This section configures the Calico API server.
# For more information, see: https://docs.tigera.io/calico/latest/reference/installation/api#operator.tigera.io/v1.APIServer
apiVersion: operator.tigera.io/v1
kind: APIServer
metadata:
  name: default
spec: {}

Nodes

main-k8s-master-1    Ready    control-plane   67m   v1.29.4
main-k8s-master-2    Ready    control-plane   68m   v1.29.4
main-k8s-master-3    Ready    control-plane   67m   v1.29.4
main-k8s-regular-1   Ready    <none>          66m   v1.29.4

All pods in calico-system namespace

NAME                                       READY   STATUS    RESTARTS   AGE
calico-kube-controllers-7f94fb7cd8-jsqpg   1/1     Running   0          8m29s
calico-node-4b9l6                          1/1     Running   0          8m29s
calico-node-88kqr                          1/1     Running   0          8m29s
calico-node-nsks9                          1/1     Running   0          8m29s
calico-node-zppdr                          1/1     Running   0          8m29s
calico-typha-677c4f7b68-6d6qn              1/1     Running   0          8m29s
calico-typha-677c4f7b68-pqwxb              1/1     Running   0          8m21s
csi-node-driver-7t6zz                      2/2     Running   0          8m29s
csi-node-driver-gpbrz                      2/2     Running   0          8m29s
csi-node-driver-rjbrg                      2/2     Running   0          8m29s
csi-node-driver-s5xhk                      2/2     Running   0          8m29s
ubuntu                                     1/1     Running   0          6m43s

Service kube-dns

kube-dns                        ClusterIP   172.31.0.10     <none>        53/UDP,53/TCP,9153/TCP   62m

From withing the pod I’m able to connect to any external public IP but the dns resolution fails because of timeout. the rest of pods ip allocation and everything works as expected.

ubuntu:~# curl google.com
curl: (6) Could not resolve host: google.com
ubuntu:~# telnet 172.31.0.10 53
telnet: can't connect to remote host (172.31.0.10): Operation timed out
ubuntu:~# telnet 142.250.181.142 443
Connected to 142.250.181.142

Although I’m able to connect with other service IP’s for example

ubuntu:~# telnet 172.31.219.128 5473
Connected to 172.31.219.128

I’m sure I’ve allowed all required ports from the firewall ingress/egress from all the k8s nodes that are listed here https://docs.tigera.io/calico/latest/getting-started/kubernetes/requirements#network-requirements

Your Environment

  • Calico version: v3.27.3
  • Kubernetes version: v1.29
  • Operating System and version: Ubuntu 22.04
  • Containerd: v1.29.0 SystemdCgroup = true Systemd Groups are configured correctly BTW

I’m new to setting up calico so I’d really appreciate all the help, I can shared the calico-node logs if that’s required.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 29 (7 by maintainers)

Most upvoted comments

I changed to using tigera-operator instead of just a manifest file. v1.34.5

We ran into a similar issue when we tested Calico. Only difference in our setup is that we run IPv6 Single-Stack. DNS was not working, but the underlying issue was deeper and general pod-to-pod traffic was not working between pods on different nodes.

Config looked as follows:

apiVersion: operator.tigera.io/v1
kind: Installation
metadata:
  annotations:
    meta.helm.sh/release-name: calico
    meta.helm.sh/release-namespace: tigera-operator
  creationTimestamp: "2024-10-18T07:58:09Z"
  finalizers:
  - operator.tigera.io/installation-controller
  - tigera.io/operator-cleanup
  - operator.tigera.io/apiserver-controller
  generation: 3
  labels:
    app.kubernetes.io/managed-by: Helm
    helm.toolkit.fluxcd.io/name: test-cluster-addons-calico
    helm.toolkit.fluxcd.io/namespace: provider
  name: default
  resourceVersion: "2351712"
  uid: 93644abd-7176-43ea-9c86-ee3b103b86b3
spec:
  calicoNetwork:
    bgp: Disabled
    hostPorts: Enabled
    ipPools:
    - allowedUses:
      - Workload
      - Tunnel
      blockSize: 122
      cidr: fd80:cafe::/104
      disableBGPExport: true
      encapsulation: VXLANCrossSubnet
      name: default-ipv6-ippool
      natOutgoing: Enabled
      nodeSelector: all()
    linuxDataplane: BPF
    multiInterfaceMode: None
    nodeAddressAutodetectionV4: {}
    nodeAddressAutodetectionV6:
      kubernetes: NodeInternalIP
    windowsDataplane: Disabled
  cni:
    ipam:
      type: Calico
    type: Calico
  controlPlaneReplicas: 2
  flexVolumePath: /usr/libexec/kubernetes/kubelet-plugins/volume/exec/
  imagePullSecrets: []
  kubeletVolumePluginPath: /var/lib/kubelet
  kubernetesProvider: ""
  logging:
    cni:
      logFileMaxAgeDays: 30
      logFileMaxCount: 10
      logFileMaxSize: 100Mi
      logSeverity: Debug
  nodeUpdateStrategy:
    rollingUpdate:
      maxUnavailable: 1
    type: RollingUpdate
  nonPrivileged: Disabled
  variant: Calico
---
apiVersion: projectcalico.org/v3
kind: FelixConfiguration
metadata:
  annotations:
    operator.tigera.io/bpfEnabled: "true"
  creationTimestamp: "2024-10-18T07:58:14Z"
  generation: 1
  name: default
  resourceVersion: "2351439"
  uid: 7d7bcc1d-ec32-4f17-9099-8b55d64a4dd2
spec:
  bpfConnectTimeLoadBalancing: TCP
  bpfEnabled: true
  bpfHostNetworkedNATWithoutCTLB: Enabled
  bpfLogLevel: ""
  floatingIPs: Disabled
  healthPort: 9099
  logSeverityScreen: Info
  reportingInterval: 0s
  vxlanVNI: 4096

The root cause in our setup seems to be that the VXLAN device is not used as routes are incorrectly set by Calico:

# ip -6 r
2001:db8::1 dev bpfin.cali metric 1024 pref medium
fd01:cafe::/64 dev eth0 proto ra metric 1024 mtu 65520 hoplimit 255 pref medium
fd80:cafe::5f:4281 dev cali3b862d89810 metric 1024 pref medium
fd80:cafe::5f:4282 dev cali9d386f561d2 metric 1024 pref medium
fd80:cafe::5f:4283 dev cali856dc622126 metric 1024 pref medium
blackhole fd80:cafe::5f:4280/122 dev lo proto 80 metric 1024 pref medium
fd80:cafe::a8:4d00/122 via fd01:cafe::f14c:9fa1:8496:5550 dev eth0 proto 80 metric 1024 onlink pref medium
fd85:cafe::a via 2001:db8::1 dev bpfin.cali src fd01:cafe::4aab:d761:d808:996 metric 1024 pref medium
fe80::/64 dev eth0 proto kernel metric 256 pref medium
fe80::/64 dev cali3b862d89810 proto kernel metric 256 pref medium
fe80::/64 dev cali9d386f561d2 proto kernel metric 256 pref medium
fe80::/64 dev bpfout.cali proto kernel metric 256 pref medium
fe80::/64 dev bpfin.cali proto kernel metric 256 pref medium
fe80::/64 dev cali856dc622126 proto kernel metric 256 pref medium
default dev eth0 proto static metric 1000 pref medium
default via fe80::ecee:eeff:feee:eeee dev eth0 proto ra metric 1024 expires 65136sec mtu 65520 hoplimit 255 pref medium

We were expecting fd80:cafe::a8:4d00/122 via fd01:cafe::f14c:9fa1:8496:5550 dev eth0 proto 80 metric 1024 onlink pref medium to go through the vxlan interface and not be directly routed to the second node (fd01...).

@matthewdupre Hopefully that helps. We are currently working around this issue by using flannel, but would prefer calico.

Glad more people are finally running into this…

I have the same problem, pods not able to resolve pods in same namespace. VMs (9) are RHEL9, k8s 1.30.4, calico 3.28.1. Using calico host firewall, no firewalld. CRI-O for runtime. Calico installed with manifest. hot fix does not work - restart coredns deployment. If i exec into an init container that is stuck with bad address output, nc gives bad address, nslookup of coredns - no route to host. To me it looks like the Pod network can not talk to the clusterip network.

Could one of you please help me out with some diags?

What I’d like to know is:

  1. Please let me know if a pod on one node can reach a pod on a different node using the destination pod’s IP directly (no service).
  2. Please capture ip addr and ip route from the nodes containing your client pod and kube-dns, and record the IP addresses of both of those pods.
  3. Are you using NodeLocalDNSCache?
  4. Please run iptables -Z on the node with the client, then try a dig, and then capture iptables-save -c from the node with the client
  5. Could you try and find out whether the problem you’re seeing is specific to first packets in a connection being dropped? I wonder whether this is why you get different results for TCP.

i dont have any firewall rules, pretty vanilla setup… for me if I only have one node, I get pods that can’t do dns/TLS verification.

I found something. If coredns pods runs on master nodes then no pod can communicate to it over tcp but if coredns runs on worker nodes then pods can connect with the coredns pods and able to resolve dns. I don’t have any specific networkpolicy configured. Does anyone know what could be the issue? From the looks of it I’d say it’s firewall issue on master node vm’s but I’ve added allow all ingress tcp 0.0.0.0/0 and that doesn’t work so it might be something else

I also have the same version v3.27.3 and encountered the same problem nc -uvz 10.10.0.2 53 is Connected, but dig timeout. It is normal if you use dig +tcp