简体   繁体   English

Kubernetes-单个Pod的可路由IP

[英]Kubernetes - Routable IP to individual Pods

I have a cluster of database nodes hosted in VMs or Bare Metal and I'd like to create additional database nodes (hosted in Kubernetes Pods) and have them join the existing cluster (ones hosted in VMs or bare metal). 我有一个托管在VM或Bare Metal中的数据库节点集群,我想创建其他数据库节点(托管在Kubernetes Pods中),并使它们加入现有集群(托管在VM或裸机中的集群)。

In order to have them join the cluster, each database must be able to resolve the other via distinct IP and port. 为了使它们加入群集,每个数据库都必须能够通过不同的IP和端口来解析另一个数据库。 Within the Kubernetes network environment, there is no issue with this and no issue between the existing VM-hosted DBs. 在Kubernetes网络环境中,与此无关,在现有的VM托管的DB之间也没有任何问题。 The sticking point is that I can't seem to see a way for the VM-hosted DBs to individually route to each POD-hosted DB. 症结在于,我似乎看不到VM托管的DB单独路由到每个POD托管的DB的方法。 Is there a Kubernetes configuration that will allow me to have each pod/DB individually routable on specific ports while sharing the same NIC for the host running the cluster? 是否有Kubernetes配置可以让我在特定端口上分别路由每个Pod / DB,同时为运行集群的主机共享相同的NIC? Do I need to front each POD with it's own Service? 我是否需要在每个POD前面加上自己的服务?

Here is the sort of configuration I'm trying to achieve with conceptual IP address spaces. 这是我尝试使用概念IP地址空间实现的那种配置。

所需的配置

The approach I take personaly for a similar case is to actualy make it possible for nodes in the non-kubernetes environment to be able to talk to the pods them selves. 在类似情况下,我个人采用的方法实际上是使非Kubernetes环境中的节点能够与他们自己的Pod对话。 Depending on your network configuration this might be quite easy to achieve. 根据您的网络配置,这可能很容易实现。

In my case I simply have 2 additional elements running on VMs that need to access my k8s internals : - flannel : this actually ties my VMs to the same flannel network as k8s pods operate in - kube-proxy : translates service ips to pod ips using iptables (in cases where I need to access by service IP) 就我而言,我只是在需要访问k8s内部的VM上运行了两个附加元素:-flannel:这实际上将我的VM与k8s pod在其中运行的同一个法兰绒网络相关联-kube-proxy:使用以下命令将服务ip转换为pod ip iptables(如果我需要通过服务IP访问)

You could avoid setting this up on VMs or their hosts if you can solve this on a gateway level (ie. have flannel/proxy on your network gate and augment it with some SNAT rules). 如果可以在网关级别解决此问题,则可以避免在VM或其主机上进行设置(例如,在网络网关上安装法兰绒/代理,并使用一些SNAT规则进行扩充)。

Having NodePort/LB service per in-k8s db might work if your DB sticks to the IPs you give (not only use for discovery bootstraping where later on the IPs are replaced with actual IPs of DBs - iirc mongo usually does something like that) 如果您的数据库坚持您提供的IP,则每个k8s数据库中的NodePort / LB服务可能会起作用(不仅用于发现引导,以后将IP替换为数据库的实际IP,iirc mongo通常会执行类似的操作)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM