From 4b93b76d590e4c60270fac33ce94468e2acada01 Mon Sep 17 00:00:00 2001 From: bdronneau Date: Tue, 14 Mar 2023 10:07:01 +0000 Subject: [PATCH 1/2] backport of commit d663303e4b20636212ace9cad80fb1b671ce7a64 --- website/content/docs/services/discovery/dns-dynamic-lookups.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/content/docs/services/discovery/dns-dynamic-lookups.mdx b/website/content/docs/services/discovery/dns-dynamic-lookups.mdx index d4c8a3fa9eae..c8c1301e94e2 100644 --- a/website/content/docs/services/discovery/dns-dynamic-lookups.mdx +++ b/website/content/docs/services/discovery/dns-dynamic-lookups.mdx @@ -5,7 +5,7 @@ description: -> Learn how to dynamically query the Consul DNS using prepared queries, which enable robust service and node lookups. --- -# Enable dynamic DNS aueries +# Enable dynamic DNS queries This topic describes how to dynamically query the Consul catalog using prepared queries. Prepared queries are configurations that enable you to register a complex service query and execute it on demand. For information about how to perform standard node and service lookups, refer to [Perform Static DNS Queries](/consul/docs/services/discovery/dns-static-lookups). From ebd4ed8a77e53323147c91b0db47b6143712478b Mon Sep 17 00:00:00 2001 From: bdronneau Date: Tue, 14 Mar 2023 10:07:43 +0000 Subject: [PATCH 2/2] backport of commit f6d5cd04813072529e58415e39a6b3743f6ef90b --- .../discovery/dns-dynamic-lookups.mdx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/website/content/docs/services/discovery/dns-dynamic-lookups.mdx b/website/content/docs/services/discovery/dns-dynamic-lookups.mdx index c8c1301e94e2..c11172756b65 100644 --- a/website/content/docs/services/discovery/dns-dynamic-lookups.mdx +++ b/website/content/docs/services/discovery/dns-dynamic-lookups.mdx @@ -20,7 +20,7 @@ If ACLs are enabled, the querying service must present a token linked to permiss - [Prepared query rules](/consul/docs/security/acl/acl-rules#prepared-query-rules) - [Service rules](/consul/docs/security/acl/acl-rules#service-rules) -- [Node rules](/consul/docs/security/acl/acl-rules#node-rules) +- [Node rules](/consul/docs/security/acl/acl-rules#node-rules) ## Create prepared queries Refer to the [prepared query reference](/consul/api-docs/query#create-prepared-query) for usage information. @@ -41,22 +41,22 @@ Refer to the [prepared query reference](/consul/api-docs/query#create-prepared-q "Near": "node1", "OnlyPassing": false, "Tags": ["primary", "!experimental"], - "NodeMeta": { - "instance_type": "m3.large" - }, - "ServiceMeta": { - "environment": "production" - } + "NodeMeta": { + "instance_type": "m3.large" }, + "ServiceMeta": { + "environment": "production" + } + }, "DNS": { "TTL": "10s" - } + } } ``` Refer to the [prepared query configuration reference](/consul/api-docs/query#create-prepared-query) for information about all available options. -1. Send the query in a POST request to the [`/query` API endpoint](/consul/api-docs/query). If the request is successful, Consul prints an ID for the prepared query. +1. Send the query in a POST request to the [`/query` API endpoint](/consul/api-docs/query). If the request is successful, Consul prints an ID for the prepared query. In the following example, the prepared query configuration is stored in the `payload.json` file: @@ -64,19 +64,19 @@ Refer to the [prepared query reference](/consul/api-docs/query#create-prepared-q $ curl --request POST --data @payload.json http://127.0.0.1:8500/v1/query {"ID":"014af5ff-29e6-e972-dcf8-6ee602137127"}% ``` -1. To run the query, send a GET request to the endpoint and specify the ID returned from the POST call. +1. To run the query, send a GET request to the endpoint and specify the ID returned from the POST call. ```shell-session $ curl http://127.0.0.1:8500/v1/query/14af5ff-29e6-e972-dcf8-6ee602137127/execute\?near\=_agent ``` - + ## Execute prepared queries You can execute a prepared query using the standard lookup format or the strict RFC 2782 SRV lookup. ### Standard lookup Use the following format to execute a prepared query using the standard lookup format: - + ``` .query[.]. ``` @@ -93,9 +93,9 @@ _._tcp.query[.]. For additional information about following the RFC 2782 SRV lookup format in Consul, refer to [RFC 2782 Lookup](/consul/docs/services/discovery/dns-static-lookups#rfc-2782-lookup). For general information about the RFC 2782 specification, refer to [A DNS RR for specifying the location of services \(DNS SRV\)](https://tools.ietf.org/html/rfc2782). ### Lookup options -The `datacenter` subdomain is optional. By default, the lookup queries the datacenter of this Consul agent. +The `datacenter` subdomain is optional. By default, the lookup queries the datacenter of this Consul agent. -The `query name` or `id` subdomain is the name or ID of an existing prepared query. +The `query name` or `id` subdomain is the name or ID of an existing prepared query. ## Results -To allow for simple load balancing, Consul returns the set of nodes in random order for each query. Prepared queries support A and SRV records. SRV records provide the port that a service is registered. Consul only serves SRV records if the client specifically requests them. \ No newline at end of file +To allow for simple load balancing, Consul returns the set of nodes in random order for each query. Prepared queries support A and SRV records. SRV records provide the port that a service is registered. Consul only serves SRV records if the client specifically requests them.