领事不注销僵尸服务 [英] Consul not deregistering zombie services

查看:210
本文介绍了领事不注销僵尸服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在马拉松部署一个简单的hello world nginx容器,一切似乎都很好,除了我有6个容器,不会从领事撤销注册。 docker ps 显示没有任何容器正在运行。



我尝试使用 / v1 / catalog / deregister 端点来注销服务,但是他们不断回来。然后我杀了注册商的容器,并尝试重新注销。他们回来了。



我正在使用

  docker run -d --name agent-registrator -v /var/run/docker.sock:/tmp/docker.sock --net = host gliderlabs / registrator consul://127.0.0.1:8500 -deregister-on-success -cleanup 

有1名领事代理运行。



重新启动机器(这是本地vm上的单个节点安装)不会使服务消失。



如何使这些容器脱离? p>

解决方案

使用http api删除服务是另一个更好的解决方案。我想知道如何手动删除服务,然后才想出如何使用https api。



要使用http api删除服务,请使用以下命令:

curl -v -X PUT http://< consul_ip_address>:8500 / v1 / agent / service / deregister /< ServiceID>



请注意,您是三件事的组合:容器运行的主机的IP地址,名称容器的内部端口(即apache为80,节点j为3000,django为8000,等等)全部由colins分开



是一个实际看起来像的例子:

curl -v -X PUT http://1.2.3.4: 8500 / v1 / agent / service / deregister / 192.168.1.1:sharp_apple:80



如果你想要一个简单的方法获取ServiceID,然后只是卷曲包含僵尸的服务:

curl -s http://< consul_ip_address>:8500 / v1 / catalog / service /< your_services_name> ;



是一个名为someapp的服务的真实示例,将返回其下的所有服务:

curl -s http://1.2.3.4:8500/v1/catalog/service/someapp


I am deploying a simple hello world nginx container with marathon, and everything seems to work well, except that I have 6 containers that will not deregister from consul. docker ps shows none of the containers are running.

I tried using the /v1/catalog/deregister endpoint to deregister the services, but they keep coming back. I then killed the registrator container, and tried deregistering again. They came back.

I am running registrator with

docker run -d --name agent-registrator -v /var/run/docker.sock:/tmp/docker.sock --net=host gliderlabs/registrator consul://127.0.0.1:8500 -deregister-on-success -cleanup

There is 1 consul agent running.

Restarting the machine (this is a single node installation on a local vm) does not make the services go away.

How do I make these containers go away?

解决方案

Using the http api for removing services is another much nicer solution. I just figured out how to manually remove services before I figured out how to use the https api.

To delete a service with the http api use the following command: curl -v -X PUT http://<consul_ip_address>:8500/v1/agent/service/deregister/<ServiceID>

Note that your is a combination of three things: the IP address of host machine the container is running on, the name of the container, and the inner port of the container (i.e. 80 for apache, 3000 for node js, 8000 for django, ect) all separated by colins :

Heres an example of what that would actually look like: curl -v -X PUT http://1.2.3.4:8500/v1/agent/service/deregister/192.168.1.1:sharp_apple:80

If you want an easy way to get the ServiceID then just curl the service that contains a zombie: curl -s http://<consul_ip_address>:8500/v1/catalog/service/<your_services_name>

Heres a real example for a service called someapp that will return all the services under it: curl -s http://1.2.3.4:8500/v1/catalog/service/someapp

这篇关于领事不注销僵尸服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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