Hi,
I must be missing something obvious, just playing around with Consul and trying to query the service meta data via DNS. Here is my service JSON and I subsequently have run consul reload
/ # cat /consul/config/counting.json
{
"service": {
"name": "counting",
"meta": {
"author": "John Smith",
"version": "1.0.0",
"description": "A web application for managing customer accounts"
},
"tags": ["go"],
"port": 9001
}
}
But when I do a SRV DNS query, I don’t get the metadata. Is it not possible to get the service metadata?
dig @127.0.0.1 -p 8600 counting.service.consul SRV
; <<>> DiG 9.16.1-Ubuntu <<>> @127.0.0.1 -p 8600 counting.service.consul SRV
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6131
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 3
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;counting.service.consul. IN SRV
;; ANSWER SECTION:
counting.service.consul. 0 IN SRV 1 1 9001 client-1.node.dc1.consul.
;; ADDITIONAL SECTION:
client-1.node.dc1.consul. 0 IN A 172.17.0.2
client-1.node.dc1.consul. 0 IN TXT "consul-network-segment="
;; Query time: 0 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Wed Apr 26 10:30:46 EDT 2023
;; MSG SIZE rcvd: 148
maxb
April 26, 2023, 4:13pm
2
I think you may have just imagined the existence of a nonexistent feature?
Do you have any links to documentation which indicates any exposure of service metadata over DNS?
blake
May 1, 2023, 5:39pm
3
Hi @rishid_hashicorp ,
maxb is correct, the DNS server does not currently send service metadata as TXT records in DNS responses. This is currently only supported for node metadata, and is enabled by default, but can be toggled using the dns_config.enable_additional_node_meta_txt
agent configuration option.
Someone opened a GitHub issue a few years ago requesting support for sending service metadata, but it hasn’t seen a lot of interest and so it has not yet been selected for development.
opened 07:37AM - 23 Sep 20 UTC
type/enhancement
theme/dns
#### 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/blob/master/doc/service_config.md)
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.