Search code examples
dockerkubernetesnetwork-programmingiptablesflannel

pods have no access to the internet


I have a freshly created kubernetes cluster set on 2 nodes, both nodes are open to the internet. I can curl, ping etc. any web. The problem appear when I try to do the same from pod. eg. curl to yoururl.com from node returns 200 and some response the same curl from inside of alpine pod returns 301 Moved Permanently The k8s network is managed by flannel. What bothers me is iptables Chain Forward that was added after k8s installation (screen below). Is this default behavior of flannel? Should I change it to ACCEPT policy? enter image description here


Solution

  • If you are experiencing issues with accessing external websites from your pods, it is possible that your nodes are not configured to use the correct DNS server. You can try adding the following configuration to your pod's YAML

    spec:   
        dnsPolicy: "Default"