简体   繁体   English

如何在任务定义中为 AWS ECS 上运行的 mosquitto-eclipse 配置健康检查?

[英]How to configure health checks for mosquitto-eclipse running on AWS ECS in the task definition?

Right now i have deployed mosquitto-eclipse successfully on Amazon ECS but i want to configure health checks in the task definition现在我已经在 Amazon ECS上成功部署了 mosquitto-eclipse,但我想在任务定义中配置运行状况检查

Note mosquitto uses port 1883 and port 9001注意mosquitto 使用端口 1883 和端口 9001

Issue问题

commands like curl are not installed in the mosquitto-eclipse image,so something like像 curl 这样的命令没有安装在 mosquitto-eclipse 图像中,所以像

CMD-SHELL curl -f http://localhost:1883 || exit 1

wont work because curl is not installed无法工作,因为未安装 curl

question问题

how do i correctly health check my mqtt mosquitto from the task definition ?我如何从任务定义中正确地检查我的 mqtt mosquitto ?

tried试过了

/ # wget --quiet --spider --tries=1 "http://localhost:9001"

but i get this error但我收到这个错误

wget: error getting response: Address not available

also something worth mentioning i have username and password set up in mosquitto say还有值得一提的事情,我在 mosquitto 中设置了用户名和密码说

username:abc

password:xyz

so maybe that is why wget is failing ?所以也许这就是 wget 失败的原因? if so how do i specify the username and password in wget ?如果是这样,我如何在 wget 中指定用户名和密码?

The short answer is, you don't.简短的回答是,你没有。 HealthChecks are what are run against your container by another service. HealthChecks 是由另一个服务针对您的容器运行的。 For instance your ALB load balancer to decide if the container task is healthy and to route traffic there.例如,您的 ALB 负载均衡器决定容器任务是否正常并将流量路由到那里。 You don't make requests to your container from inside your container, that's the end of the story.您不会从容器内部向容器发出请求,这就是故事的结尾。

However, nothing stops you have from having an health check endpoint in your service which returns data when requested.但是,没有什么可以阻止您在服务中拥有一个运行状况检查端点,该端点在请求时返回数据。 You would need to compose a container which runs two services, the Mosquitto and a second webservice to monitor the container.您需要编写一个运行两个服务的容器,Mosquitto 和第二个 Web 服务来监视容器。

However, based on what you are looking for, you should be monitoring the service from outside of the ECS task.但是,根据您要查找的内容,您应该从 ECS 任务外部监视服务。 You can either deploy another task or use the built in metrics/alarms to determine how to adjust the autoscaling when necessary.您可以部署另一个任务或使用内置指标/警报来确定如何在必要时调整自动缩放。 Don't build your own solution.不要构建自己的解决方案。

Further, you don't and shouldn't deploy mosquitto to AWS, because AWS already natively supports MQTT message brokers via Amazon MQ service此外,您不会也不应该将 mosquitto 部署到 AWS,因为 AWS 已经通过Amazon MQ 服务原生支持 MQTT 消息代理

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

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