简体   繁体   English

如何在 Docker 中访问 Kubernetes Pod?

[英]How to access a Kubernetes Pod in Docker?

The setup below is all done on Google Cloud.下面的设置都是在 Google Cloud 上完成的。

  • I have a Docker setup running on a VM instance having a Hyperledger Fabric Network of 3 Orderers and 2 peers of a single organization.我有一个在 VM 实例上运行的 Docker 设置,该实例具有一个由 3 个订购者和 2 个同级组织组成的 Hyperledger Fabric 网络。

  • I have a Kubernetes Cluster running on GKE having just 2 peer pods.我有一个在 GKE 上运行的 Kubernetes 集群,只有 2 个对等 Pod。

What I want to achieve is:我想要实现的是:

I want the peer pod of Kubernetes to be able to communicate with the network setup in Docker.我希望 Kubernetes 的对等 Pod 能够与 Docker 中的网络设置进行通信。 ie I want at least 1 peer of the Kubernetes to be able to join the network channel on the Docker Network and be able to perform some transaction/query.即我希望 Kubernetes 的至少 1 个对等方能够加入 Docker 网络上的网络通道并能够执行一些事务/查询。

Till now what I have done is exposed the services of the 2 peer pods in Kubernetes ie ClusterIP -> NodePort.到目前为止,我所做的是公开 Kubernetes 中的 2 个对等 Pod 的服务,即 ClusterIP -> NodePort。

I have done some reading as to what options are there such as having an Nginx proxy and other things, but I am new to this and still in a beginner phase so a few things are still confusing to me.我已经阅读了一些关于有哪些选项(例如拥有 Nginx 代理和其他东西)的阅读资料,但我对此很陌生并且仍处于初学者阶段,所以有些事情仍然让我感到困惑。

Any help would be appreciated.任何帮助,将不胜感激。

Since you have two separate container setups (and two different container technologies), containers in one space have to communicate with the other as though they're outside the cluster.由于您有两个单独的容器设置(和两种不同的容器技术),一个空间中的容器必须与另一个空间通信,就好像它们在集群之外一样。 You can't join arbitrary Docker containers on another instance into the Kubernetes network environment, nor can you join Kubernetes pods into a single-host Docker network environment.您不能将另一个实例上的任意 Docker 容器加入到 Kubernetes 网络环境中,也不能将 Kubernetes pod 加入到单主机 Docker 网络环境中。

Using a NodePort or LoadBalancer-type Service as you already have is close to the best you can do, particularly if the underlying protocol isn't HTTP.使用您已有的 NodePort 或 LoadBalancer 类型的服务几乎是您所能做的最好的事情,尤其是在底层协议不是 HTTP 的情况下。 If you need a multi-host setup, migrating the whole thing into GKE might be a better long-term answer.如果您需要多主机设置,将整个内容迁移到 GKE 可能是一个更好的长期解决方案。

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

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