hashicorp / consul

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
https://www.consul.io
Other
28.26k stars 4.41k forks source link

Add services metadata to TXT DNS records #8733

Open amenzhinsky opened 4 years ago

amenzhinsky commented 4 years ago

Feature Description

Currently only node_meta is exposed in DNS queries as TXT records when enable_additional_node_meta_txt is on and there's no way to add separate TXT records for services.

Add enable_additional_service_meta_txt (default false) flag and when it's enabled expose services' metadata just like node_meta in TXT queries.

Use Case(s)

Golang and C/C++ gRPC drivers make use of TXT records as a source of service config

https://github.com/grpc/grpc-go/blob/master/internal/resolver/dns/dns_resolver.go#L61 https://github.com/grpc/grpc/blob/16b0cf0944a0a29c7a12d3a69293c82daa56cdc3/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc#L339

If this accepted I can implement it.

blake commented 3 years ago

@amenzhinsky Its not clear to me that including TXT records in the additional section of a DNS response would be sufficient to support gRPC's Service Config via DNS.

The lookup() function in grpc/grpc-go/internal/resolver/dns/dns_resolver.go explicitly performs a TXT lookup to retrieve the service config, which means that for this query to work Consul would need to return the grpc_config= in response to a TXT lookup for _grpc_config.<service>.service.consul.

Does this seem correct, or is there something I'm missing?

amenzhinsky commented 3 years ago

@blake It would we played around with custom dns proxy that uses consul as a backend.

Yes it does, you're not missing anything.

amenzhinsky commented 3 years ago

@blake hold on, my bad, TXT lookups have to look like _grpc_config.{service_name} so this involves DNS resolver updates, not sure whether this has to be implemented in consul.