How to connect a pod to internet ? [K8S]

6/25/2020
  1. I installed Kubernetes "the kubeadm way"
  2. I joined two nodes

When I run an nginx pod then try to curl www.google.com it fails.

$ kubectl exec -it nginx -- sh 
# curl http://google.com
'curl: (6) Could not resolve host: google.com

How can I resolve this ?

  • I disabled firewalld on master and worker nodes
  • I am running K8S behind a corporate proxy
  • I added the ip address of the Api server to NO_PROXY list ( on master and worker nodes)
  • I added the ip address of the worker nodes to NO_PROXY list ( on the master node)

cni conf:

    "cniVersion": "0.3.1",
    "name": "crio",
    "type": "bridge",
    "bridge": "cni0",
    "isGateway": true,
    "ipMasq": true,
    "hairpinMode": true,
    "ipam": {
        "type": "host-local",
        "routes": [
            { "dst": "0.0.0.0/0" },
            { "dst": "1100:200::1/24" }
        ],
        "ranges": [
            [{ "subnet": "10.85.0.0/16" }],
            [{ "subnet": "1100:200::/24" }]
        ]
    }
}

When I run nginx container with podman then try to execute a curl within the container : $ curl http://google.com (timeout)

-- Watermelon
kubernetes

1 Answer

6/25/2020

Try this:

  1. Delete the cluster by running kubeadm reset
  2. Delete /opt/bni/bin/weave-*.
  3. Restart the machine before creating new cluster by kubeadm init.

Looking like the following issue:

https://github.com/weaveworks/weave/issues/2888

-- Sanket Singh
Source: StackOverflow