【问题标题】:Kubernetes internet access with two network interfaces具有两个网络接口的 Kubernetes 互联网访问
【发布时间】:2019-02-16 10:51:37
【问题描述】:

我是 Kubernetes 的新手,我有一个关于 Kubernetes 网络的问题。 在我的设置中,每个节点都有两个接口。第一个接口 (eth0) 在私有范围内(例如 172.20.12.10),第二个有一个公共地址。

auto eth0 
iface eth0 inet static
    address 172.20.12.10
    netmask 255.255.0.0
    network 172.20.0.0
    broadcast 172.16.255.255
    dns-nameservers 8.8.8.8
auto eth1
iface eth1 inet static
address x.x.x.x
gateway y.y.y.y 

显然 kubernetes 网络配置依赖于节点默认网关,因此上述节点网络配置无法正常工作。

我的问题是:如何在我的容器中访问互联网?

【问题讨论】:

    标签: kubernetes containers


    【解决方案1】:

    kubeadm init--apiserver-advertise-address 参数可用于使 k8s 使用不同于节点默认网络接口的接口:

    --apiserver-advertise-address string
        The IP address the API Server will advertise it's listening on.
        Specify '0.0.0.0' to use the address of the default network interface.
    

    另外,向/etc/systemd/system/kubelet.service.d/10-kubeadm.conf 添加一个标志,指定工作节点的私有IP:

    --node-ip=<private-node-ip>
    

    最后,当您在工作节点上运行 kubeadm join 时,请确保您提供 API 服务器的私有 IP。

    更多信息在:

    【讨论】:

    • 现在在容器中我可以访问互联网,也可以访问私有网络,但无法访问其他容器(例如它无法访问 kubernetes dns 服务)
    猜你喜欢
    • 1970-01-01
    • 2017-06-24
    • 2015-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多