我正在关注下面有关领事学习的教程()。
一切对我来说都是有意义的,直到Envoy Sidecar代理以命令 Connect connect-sidecar-sidecar-for service-id 开始。
通常,当我在领事中注册服务时,我会为服务生成一个随机ID,为此,试图以这种方式启动代理是不可能的,因为我不知道启动Sidecar代理时生成的ID。我想到的是在启动期间以编程方式启动服务代理,这样我就可以访问服务ID,然后使用它来启动它。有什么方法可以通过编程方式执行此操作?,是否有不同的方法可以通过运行Consul CLI命令来完成?
谢谢。
I was following the following tutorial on consul learn (https://learn.hashicorp.com/tutorials/consul/service-mesh-with-envoy-proxy).
Everything makes sense to me up until the point where the envoy sidecar proxy is started with the command consul connect envoy -sidecar-for service-id.
Usually when I register a service in consul, I generate a random id for the service and for that matter, trying to start the proxy this way would be impossible because I do not know the generated id as at the time of starting the sidecar proxy. What I thought of was to programmatically start the sidecar proxy in the service during startup, that way I have access to the service id and then I use that to start it. Is there any way to do this programmatically?, are there different ways this can be done aside running the consul cli command?.
Thanks.
发布评论
评论(1)
如果任何人感兴趣,我仍然找不到一种方法来启动Envoy Sidecar代理与我的代码服务一起,但是经过一些研究,我意识到这样做的更合适的方法是使用 hashicorp等部署平台Nomad 或 kubernettes 。对于Nomad,您基本上使用配置文件中的Sidecar代理来定义您的服务,并且它会启动它们。这实际上是有道理的,因为在大多数情况下,在微服务部署中,您将需要此类工具来减轻部署。
以下是启动服务和边车代理的示例游牧代码。
In case anyone is interested, I still could not find a way to start the envoy sidecar proxy alongside my service in code, but after some research, I realized the more appropriate way to do this is to use a deployment platform like Hashicorp Nomad or kubernettes. In the case of Nomad, you basically define your service with a sidecar proxy in a configuration file and it takes care of starting them. It actually makes sense because for the most part in microservice deployments, you would need such tools to ease your deployments.
Below is a sample nomad code to start a service and a sidecar proxy.