我是 Kubernetes 的新手,我有一个关于 Kubernetes 网络的问题。
在我的设置中,每个节点都有两个接口(interface)。第一个接口(interface) (eth0) 位于私有(private)范围内(例如 172.20.12.10),第二个接口(interface)具有公共(public)地址。
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 网络配置取决于节点默认网关,因此上述节点网络配置无法正常工作。
我的问题是:如何在我的容器中访问互联网?
最佳答案
--apiserver-advertise-address
kubeadm init
的参数可用于使 k8s 使用不同于节点默认网络接口(interface)的接口(interface):
--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
中添加一个标志指定工作节点的私有(private) IP:--node-ip=<private-node-ip>
最后,当你运行
kubeadm join
在工作节点上,确保提供 API 服务器的私有(private) IP。更多信息在:
关于具有两个网络接口(interface)的 Kubernetes 互联网访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54722289/