Consul 中删除一个 instance 可以使用 Consul API,具体的 curl 命令如下:
curl --request PUT --url http://localhost:8500/v1/agent/service/deregister/<service-id>
其中,<service-id>
是要删除的 instance 的 Service ID。您可以通过 consul catalog services
命令查看当前可用的所有服务及其 Service ID。
以下是一个示例命令,假设要删除 Service ID 为 “web-1” 的 instance:
curl --request PUT --url http://localhost:8500/v1/agent/service/deregister/web-1
执行该命令后,Consul 将从其服务目录中移除该 instance,并在其他节点上进行广播以确保该实例已从整个 Consul 集群中注销。