简体   繁体   English

如何在 Kuma 或任何其他服务网格中的另一个 SpringBoot 应用程序中作为 SideCar 代理注入 SpringBoot 应用程序

[英]How to inject on SpringBoot application as SideCar Proxy in another SpringBoot application in Kuma or any other Service Mesh

I know how to use Kuma or Istio as Service Mesh and inject one SideCar proxy into one existing SpringBoot Application or any other Application but can we inject one SpringBoot application as SideCar Proxy into another SpringBoot Application.我知道如何使用 Kuma 或 Istio 作为服务网格并将一个 SideCar 代理注入一个现有的 SpringBoot 应用程序或任何其他应用程序,但我们可以将一个 SpringBoot 应用程序作为 SideCar 代理注入另一个 SpringBoot 应用程序。

The context is, lets say SideCar Proxy SpringBoot application might be having basic things (ie Authentication, Security Policy or any other type of policy etc) which might be required in main SpringBoot Service.上下文是,可以说 SideCar 代理 SpringBoot 应用程序可能具有主 SpringBoot 服务中可能需要的基本内容(即身份验证、安全策略或任何其他类型的策略等)。 And the same SideCar proxy application can be injected into any other application.并且同一个 SideCar 代理应用程序可以注入到任何其他应用程序中。

Question might sound little vague but I can provide more details on it if anything is not clear or confusing.问题可能听起来有点模糊,但如果有任何不清楚或令人困惑的地方,我可以提供更多详细信息。

Thanks谢谢

To my knowledge, this is not possible in Kuma or any other service mesh.据我所知,这在 Kuma 或任何其他服务网格中是不可能的。 I believe what you are asking for is the ability to customize/replace the proxy used by the service mesh.我相信您要求的是能够自定义/替换服务网格使用的代理。 In the case of Kuma and Istio, which use Envoy as the sidecar proxy, you would need to reimplement most of Envoy in your Springboot application.对于使用 Envoy 作为 sidecar 代理的 Kuma 和 Istio,您需要在 Springboot 应用程序中重新实现大部分 Envoy。

I think you are better off trying to move the logic in your SpringBoot "sidecar" into either Kuma policies or into some gateway.我认为您最好尝试将 SpringBoot“sidecar”中的逻辑移动到 Kuma 策略或某个网关中。 Apache APISIX , for example, has support for Java plugins .例如, Apache APISIX 支持 Java 插件

I am not sure that I have got the question correctly.我不确定我是否正确回答了这个问题。 It looks like you need to have two SpringBoot applications , one will be the main app, and the other will be a sidecar for it.看起来您需要有两个 SpringBoot 应用程序,一个是主应用程序,另一个是它的边车。 That does not sound like an unusual thing.这听起来不像是一件不寻常的事情。

Here is a sample of Kubernetes deployment.yaml you might have:以下是您可能拥有的 Kubernetes deployment.yaml 示例:

apiVersion: apps/v1
kind: Deployment
metadata:
 name: sidecar-deployment
 labels:
   role: app
spec:
 replicas: 1
 selector:
   matchLabels:
     role: app
 template:
   metadata:
     labels:
       role: app
   spec:
     volumes:
     - name: shared-data
       emptyDir: {}
     containers:
     - name: mainapp
       image: "dokerhubuser/mainapp"
       volumeMounts:
       - name: shared-data
         mountPath: /usr/share/mainapp-folder
       ports:
       - containerPort: 8080
     - name: sidecar
       image: "dokerhubuser/sidecar"
       volumeMounts:
       - name: shared-data
         mountPath: /usr/share/sidecar-folder
       ports:
       - containerPort: 8888

Look here for more details about this yaml file: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/在此处查看有关此 yaml 文件的更多详细信息: https ://kubernetes.io/docs/concepts/workloads/controllers/deployment/

This is very basic.这是非常基本的。 The main point is that the sidecar is a second container on the same deployment.重点是 sidecar 是同一部署中的第二个容器。

They will share the same filesystem.他们将共享相同的文件系统。 Sidecar app can be addressed via localhost: (eg HTTP://localhost:8888 in our case) Sidecar 应用程序可以通过 localhost 寻址:(例如 HTTP://localhost:8888 在我们的例子中)

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

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