No internet connectivity inside docker container running inside kubernetes with weave as networking

前端 未结 3 1526
执念已碎
执念已碎 2021-01-13 11:29

I have a kubernetes cluster that is running on AWS EC2 instances and weave as networking(cni). I have disabled the docker networking(ipmask and iptables) as it is managed by

相关标签:
3条回答
  • 2021-01-13 12:04

    You can try to attach weave networking dynamically as a part of your build job. Is it definitely possible to change active network of container on the flight with weave.

    Maybe you will need to use some additional container with Weave Docker Api Proxy or you can use a different way to communicate with Weave network on your nodes.

    So, the main idea is just attach your containers where you running builds to the Kubernetes pods network, where you have an external access.

    Also, and maybe it will be better, you can create another one Weave virtual network with access to the Internet and attach your contenders to it.

    0 讨论(0)
  • 2021-01-13 12:07

    Ok finally after lot of struggle I find the solution.
    So when ever K8s starts a pod it starts a sidecart container whose role is basically to provide network to pod containers.
    So while running docker build if I pass it's container ID as network then my intermediate contexts start getting internet connectivity via this container. So changes looks something like this:

    docker build -t "some name" --network container:\$(docker ps | grep \$(hostname) | grep k8s_POD | cut -d\" \" -f1) -f infra/docker/Dockerfile .
    

    Hope this helps. :D

    0 讨论(0)
  • 2021-01-13 12:10

    You're right - the docker build process runs in a different context, and Weave Net doesn't attach those automatically.

    Even more complicated, Kubernetes will connect via CNI whereas Docker has its own plugin API. I believe it's possible to have both on a machine at the same time, but rather complicated.

    Maybe look at some of the ways to build images without using Docker ?

    0 讨论(0)
提交回复
热议问题