简体   繁体   English

是否可以使用Kubernetes Pod在同一子网中加入硬件?

[英]Is it possible to join a hardware in the same subnet with Kubernetes pods?

I have setup a Kubernetes cluster with flannel network on bare metal. 我已经在裸机上设置了带有绒布网络的Kubernetes集群。 I have a service deployed and running in the cluster. 我已经在集群中部署并运行了一项服务。 The service would broadcast to discover the other end devices in the same subnet. 该服务将广播以发现同一子网中的其他终端设备。

The problem is that the client agents which receives the broadcasts are running on resource-constrained hardware. 问题在于,接收广播的客户端代理正在资源受限的硬件上运行。 These devices are running in the same subnet with the Master and Worker Nodes. 这些设备与主节点和工作节点在同一子网中运行。 The deployed service in pods (netmask: 10.244.0.0/16) are unable to discover the clients running in the Host OS subnet (netmask: 192.168.0.0/24). 在pod(网络掩码:10.244.0.0/16)中部署的服务无法发现在主机OS子网(网络掩码:192.168.0.0/24)中运行的客户端。 How to join the clients in the pods' subnet? 如何在Pod的子网中加入客户端?

Any help is appreciate. 任何帮助表示赞赏。

The issue is that they are actually in different subnets: the pod network and the bare-metal network. 问题在于它们实际上位于不同的子网中:Pod网络和裸机网络。 Therefore you would have to check what options are available for service discovery between different subnets. 因此,您必须检查哪些选项可用于不同子网之间的服务发现。 Some propose the use of a tracker (just like P2P networks work) https://serverfault.com/a/304344/380575 . 有些人建议使用跟踪器(就像P2P网络一样工作) https://serverfault.com/a/304344/380575

You could also try adding external services/endpoints to the services running outside the cluster, but I am quite uncertain that this could work. 您也可以尝试将外部服务/端点添加到在群集外部运行的服务,但是我不确定这是否可行。

Bottom line: If you need services in other subnets, you can either use a tracker or create static endpoints to them. 底线:如果您需要其他子网中的服务,则可以使用跟踪器或为它们创建静态端点。

I ended up making the host and pods running in the same subnet by adding hostNetwork: true in pod configuration. 我最终通过添加hostNetwork: true在pod配置hostNetwork: true主机和pod在同一子网中运行。 In that case, containers are using host network. 在这种情况下,容器正在使用主机网络。 Inspired from here 这里启发

The configuration looks like: 配置如下:

apiVersion: v1
kind: ReplicationController
metadata:
 name: worker
 namespace: default
spec:
 replicas: 4
 selector:
   name: worker
 template:
   metadata:
     labels:
       name: worker
 spec:
    hostNetwork: true
    containers:
       - image: 10.0.0.1:5000/worker
         name: worker
         imagePullPolicy: IfNotPresent

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

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