2
votes

I've created a bunch of test services in my consul cluster I wish to remove, I have tried using the /v1/agent/service/deregister/{service id} - and ensured it runs fine on each node - I can see this run on each node

[INFO] agent: Deregistered service 'ci'

Is there another way to manually clean out these old services ?

Thanks,

4

4 Answers

8
votes

Try this

$ curl \
--request PUT \
https://consul.rocks/v1/agent/service/deregister/my-service-id
4
votes
  1. fetch service info curl $CONSUL_AGETNT_ADDR:8500/v1/catalog/service/$SERVICE_NAME | python -mjson.tool :

    { "Address": "10.0.1.2", "CreateIndex": 30242768, "Datacenter": "", "ID": "", "ModifyIndex": 30550079, "Node": "log-0", "NodeMeta": null, "ServiceAddress": "", "ServiceEnableTagOverride": false, "ServiceID": "log", "ServiceName": "log", "ServicePort": 9200, "ServiceTags": [ "log" ], "TaggedAddresses": null }, ...

  2. prepare a json file, fulfill the values with the above outputs cat > data.json :

    { "Datacenter": "", "Node": "log-0", "ServiceID": "log-0" }

  3. deregister with: curl -X PUT -d @data.json $CONSUL_AGETNT_ADDR:8500/v1/catalog/deregister

4
votes

Login in to the consul machine,and issue the command as follow:

consul services deregister -id={Your Service Id}
0
votes

You can clear service config in config directory mannually