GCP中kubernetes内同一节点上Pod到Pod的通信 [英] Communication from Pod to Pod on same node inside kubernetes in GCP

查看:246
本文介绍了GCP中kubernetes内同一节点上Pod到Pod的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为kubernetes中的front(REACT)和backend(EXPRESS NODE JS)项目进行了docker化并创建了部署和服务.我已经在Google Cloud Platform中的两个Pod(即一个Pod-> REACT APP和SECOND POD-> EXPRESS NODE JS )的同一节点的Kubernetes(单节点集群)中成功部署了.

I have dockerized and created deployment and service for both front(REACT) and backend (EXPRESS NODE JS) project in kubernetes. I have successfully deployed in Kubernetes(Single node cluster) in Same Node with Two Pods(i.e One Pod --> REACT APP and SECOND POD --> EXPRESS NODE JS) in Google cloud Platform.

问题:

Question:

1.)如何在Kubernetes集群中的Node内从一个Pod到另一个Pod进行通信?

1.) How to communicate from one pod to another pod inside the Node in Kubernetes cluster?

2.)我已通过在 kubernetes 中创建 LoadBalancer 类型服务将我的REACT应用暴露给外界,并且我能够从浏览器访问React App端点.现在,是否可以从节点内的REACT应用程序访问EXPRESS应用程序而无需将我的EXPRESS应用程序暴露于外界.如何实现呢?

2.) I have exposed my REACT app to the Outer world by creating LoadBalancer Type Service in kubernetes and i am able to access the React App Endpoint from the Browser. Now, Is it possible to access EXPRESS app from REACT app inside the node without exposing my EXPRESS app to outer world. How to achieve this?

预先感谢.

推荐答案

如果前端是基于浏览器的JavaScript应用,则可以从群集中的Pod托管JavaScript资源,但逻辑不能在其中运行.前端的JavaScript在用户的浏览器中运行.从用户的浏览器调用集群中的任何后端端点都需要在链中某个位置使用外部URL,而不仅仅是内部URL.

When the frontend is a browser-based JavaScript app then the JavaScript resources may be hosted from a Pod in the cluster but the logic doesn't run there. The fronted JavaScript runs in the user's browser. Calling any backend endpoints in the cluster from the user's browser requires an external URL somewhere along the chain and not just an internal one.

执行此操作的典型方法是设置类型为LoadBalancer的服务,并将外部端点放入后端的配置中.另一个方法是设置一个Ingress Controller,并与后端一起部署Service和Ingress.使用Ingress,您可以在部署服务之前知道外部URL是什么(如果使用DNS,这是最简单的方法).群集内部通信不需要Ingress,可以使用ClusterIP类型的服务来完成,但我认为您需要外部通信.

A typical way to do this is to set up a Service of type LoadBalancer and put the external endpoint into the backend's config. Another is to set up an Ingress Controller and deploy both Service and Ingress along with the backend. With Ingress you can know what the external URL will be before you deploy the Service (and this is easiest if you use DNS). Cluster-internal communication doesn't need Ingress and can be done with Services of type ClusterIP but I think you need external communication.

您将需要公开一个外部入口点,以便用户无论如何都可以访问UI(托管JS的位置).使用入口,您可以将到后端的路由配置为同一(外部)主机上的其他路径.

You will need to expose an external entry point for users to hit the UI anyway (the place where the JS is hosted). With ingress you could configure the route to the backend as a different path on the same (external) host.

这篇关于GCP中kubernetes内同一节点上Pod到Pod的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆