I registered a service with “curl --request PUT --data @payload.json ‘http://127.0.0.1:8500/v1/catalog/register’”. I can list the service with “/v1/catalog/service/consul_register_test10” for a short time.
However，after about 90 seconds，the service just disappeared. The list query responsed with null.
Please give me a hand and thanks.
P.S.The version is Consul v1.7.3 .
This is caused due to Consul’s anti-entropy sync - Anti-Entropy | Consul by HashiCorp.
During this synchronization, the catalog is also checked for correctness. If any services or checks exist in the catalog that the agent is not aware of, they will be automatically removed to make the catalog reflect the proper set of services and health information for that agent. Consul treats the state of the agent as authoritative; if there are any differences between the agent and catalog view, the agent-local view will always be used.
You should be registering the services via a local consul agent using the
/v1/agent/service endpoint - Service - Agent - HTTP API | Consul by HashiCorp instead of the
Thany you very much. That helps a lot.
I’m using /v1/agent/service right now. I’m running a cluster with three servers. Between services and servers,there is a nginx cluster which uses round-robin transfer policy.Sometimes i comes failures on deregistering beacause the deregistering requirement does not go to the registered node.
So there is a requirement that i should deregister services on the node which the services isn’t registered on.I’m just wondering if catalog API could make a diffrence.
From your guidence，it seems that i should always use agent to register services. Is there any solutions for my problems?
Did you use the name of an existing agent in your cluster (for
Node: field) while registering the external service? This leads to the service getting removed due to Anti-Entropy sync.
You can continue to use catalog API provided you register the service with a
Address that is not of an agent in the cluster.
Another important thing to note is that the external service by default won’t get any health checks. You will have to use Consul ESM for the same. Ref: GitHub - hashicorp/consul-esm: External service monitoring for Consul
Could you give it a try and let me know if it works for you?