Name resolution provider component specs
The supported name resolution providers to enable Dapr service invocation
The following components provide name resolution for the service invocation building block.
Name resolution components are configured via the configuration.
Table headers to note:
Header | Description | Example |
---|
Status | Component certification status | Alpha Beta Stable
|
Component version | The version of the component | v1 |
Since runtime version | The version of the Dapr runtime when the component status was set or updated | 1.11 |
Generic
Kubernetes
Component | Status | Component version | Since runtime version |
---|
Kubernetes | Stable | v1 | 1.0 |
Self-Hosted
Component | Status | Component version | Since runtime version |
---|
mDNS | Stable | v1 | 1.0 |
1 - AWS Cloudmap
Detailed information on the AWS Cloudmap name resolution component
This component uses AWS Cloud Map for service discovery in Dapr. It supports both HTTP and DNS namespaces, allowing services to discover and connect to other services using AWS Cloud Map’s service discovery capabilities.
Name resolution is configured via the Dapr Configuration.
Within the configuration YAML, set the spec.nameResolution.component
property to "aws.cloudmap"
, then pass configuration options in the spec.nameResolution.configuration
dictionary.
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
nameResolution:
component: "aws.cloudmap"
version: "v1"
configuration:
# Required: AWS CloudMap namespace configuration (one of these is required)
namespaceName: "my-namespace" # The name of your CloudMap namespace
# namespaceId: "ns-xxxxxx" # Alternative: Use namespace ID instead of name
# Optional: AWS authentication (choose one authentication method)
# Option 1: Environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
# Option 2: IAM roles for Amazon EKS
# Option 3: Explicit credentials (not recommended for production)
accessKey: "****"
secretKey: "****"
sessionToken: "****" # Optional
# Optional: AWS region and endpoint configuration
region: "us-west-2"
endpoint: "http://localhost:4566" # Optional: Custom endpoint for testing
# Optional: Dapr configuration
defaultDaprPort: 50002 # Default port for Dapr sidecar if not specified in instance attributes
Specification
AWS authentication
The component supports multiple authentication methods:
Environment Variables:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_SESSION_TOKEN (optional)
IAM Roles:
- When running on AWS (EKS, EC2, etc.), the component can use IAM roles
Explicit Credentials:
- Provided in the component metadata (not recommended for production)
Required permissions
The AWS credentials must have the following permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"servicediscovery:DiscoverInstances",
"servicediscovery:GetNamespace",
"servicediscovery:ListNamespaces"
],
"Resource": "*"
}
]
}
Spec configuration fields
Field | Required | Type | Default | Description |
---|
namespaceName | One of namespaceName or namespaceId | string | "" | The name of your AWS CloudMap namespace |
namespaceId | One of namespaceName or namespaceId | string | "" | The ID of your AWS CloudMap namespace |
region | N | string | "" | AWS region. If not provided, will be determined from environment or instance metadata |
endpoint | N | string | "" | Custom endpoint for AWS CloudMap API. Useful for testing with LocalStack |
defaultDaprPort | N | number | 3500 | Default port for Dapr sidecar if not specified in instance attributes |
Service registration
To use this name resolver, your services must be registered in AWS CloudMap. When registering instances, ensure they have the following attributes:
Required: One of these address attributes:
AWS_INSTANCE_IPV4
: IPv4 address of the instanceAWS_INSTANCE_IPV6
: IPv6 address of the instanceAWS_INSTANCE_CNAME
: Hostname of the instance
Optional: Dapr sidecar port attribute:
DAPR_PORT
: The port that the Dapr sidecar is listening on- If not specified, the component will use the
defaultDaprPort
from configuration (defaults to 3500)
The resolver only returns healthy instances (those with HEALTHY
status) to ensure reliable service communication.
Example instance attributes:
{
"AWS_INSTANCE_IPV4": "10.0.0.1",
"DAPR_PORT": "50002"
}
Example Usage
Name resolution is configured via the Dapr Configuration. Here are some examples of its usage.
Minimal Configuration
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
nameResolution:
component: "aws.cloudmap"
configuration:
namespaceName: "mynamespace.dev"
defaultDaprPort: 50002
Local Development with LocalStack
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
nameResolution:
component: "aws.cloudmap"
configuration:
namespaceName: "my-namespace"
region: "us-east-1"
endpoint: "http://localhost:4566"
accessKey: "test"
secretKey: "test"
2 - HashiCorp Consul
Detailed information on the HashiCorp Consul name resolution component
Hashicorp Consul is setup within the Dapr Configuration.
Within the config, add a nameResolution
spec and set the component
field to "consul"
.
If you are using the Dapr sidecar to register your service to Consul then you will need the following configuration:
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
nameResolution:
component: "consul"
configuration:
selfRegister: true
If Consul service registration is managed externally from Dapr you need to ensure that the Dapr-to-Dapr internal gRPC port is added to the service metadata under DAPR_PORT
(this key is configurable) and that the Consul service Id matches the Dapr app Id. You can then omit selfRegister
from the config above.
Behaviour
On init
the Consul component either validates the connection to the configured (or default) agent or registers the service if configured to do so. The name resolution interface does not cater for an “on shutdown” pattern so consider this when using Dapr to register services to Consul as it does not deregister services.
The component resolves target apps by filtering healthy services and looks for a DAPR_PORT
in the metadata (key is configurable) in order to retrieve the Dapr sidecar port. Consul service.meta
is used over service.port
so as to not interfere with existing Consul estates.
Spec configuration fields
The configuration spec is fixed to v1.3.0 of the Consul API
Field | Required | Type | Details | Examples |
---|
Client | N | *api.Config | Configures client connection to the Consul agent. If blank it will use the sdk defaults, which in this case is just an address of 127.0.0.1:8500 | 10.0.4.4:8500 |
QueryOptions | N | *api.QueryOptions | Configures query used for resolving healthy services, if blank it will default to UseCache:true | UseCache: false , Datacenter: "myDC" |
Checks | N | []*api.AgentServiceCheck | Configures health checks if/when registering. If blank it will default to a single health check on the Dapr sidecar health endpoint | See sample configs |
Tags | N | []string | Configures any tags to include if/when registering services | - "dapr" |
Meta | N | map[string]string | Configures any additional metadata to include if/when registering services | DAPR_METRICS_PORT: "${DAPR_METRICS_PORT}" |
DaprPortMetaKey | N | string | The key used for getting the Dapr sidecar port from Consul service metadata during service resolution, it will also be used to set the Dapr sidecar port in metadata during registration. If blank it will default to DAPR_PORT | "DAPR_TO_DAPR_PORT" |
SelfRegister | N | bool | Controls if Dapr will register the service to Consul. The name resolution interface does not cater for an “on shutdown” pattern so please consider this if using Dapr to register services to Consul as it will not deregister services. If blank it will default to false | true |
AdvancedRegistration | N | *api.AgentServiceRegistration | Gives full control of service registration through configuration. If configured the component will ignore any configuration of Checks, Tags, Meta and SelfRegister. | See sample configs |
Sample configurations
Basic
The minimum configuration needed is the following:
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
nameResolution:
component: "consul"
Registration with additional customizations
Enabling SelfRegister
it is then possible to customize the checks, tags and meta
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
nameResolution:
component: "consul"
configuration:
client:
address: "127.0.0.1:8500"
selfRegister: true
checks:
- name: "Dapr Health Status"
checkID: "daprHealth:${APP_ID}"
interval: "15s"
http: "http://${HOST_ADDRESS}:${DAPR_HTTP_PORT}/v1.0/healthz"
- name: "Service Health Status"
checkID: "serviceHealth:${APP_ID}"
interval: "15s"
http: "http://${HOST_ADDRESS}:${APP_PORT}/health"
tags:
- "dapr"
- "v1"
- "${OTHER_ENV_VARIABLE}"
meta:
DAPR_METRICS_PORT: "${DAPR_METRICS_PORT}"
DAPR_PROFILE_PORT: "${DAPR_PROFILE_PORT}"
daprPortMetaKey: "DAPR_PORT"
queryOptions:
useCache: true
filter: "Checks.ServiceTags contains dapr"
Advanced registration
Configuring the advanced registration gives you full control over setting all the Consul properties possible when registering.
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
nameResolution:
component: "consul"
configuration:
client:
address: "127.0.0.1:8500"
selfRegister: false
queryOptions:
useCache: true
daprPortMetaKey: "DAPR_PORT"
advancedRegistration:
name: "${APP_ID}"
port: ${APP_PORT}
address: "${HOST_ADDRESS}"
check:
name: "Dapr Health Status"
checkID: "daprHealth:${APP_ID}"
interval: "15s"
http: "http://${HOST_ADDRESS}:${DAPR_HTTP_PORT}/v1.0/healthz"
meta:
DAPR_METRICS_PORT: "${DAPR_METRICS_PORT}"
DAPR_PROFILE_PORT: "${DAPR_PROFILE_PORT}"
tags:
- "dapr"
Setup HashiCorp Consul
HashiCorp offer in depth guides on how to setup Consul for different hosting models. Check out the self-hosted guide here
HashiCorp offer in depth guides on how to setup Consul for different hosting models. Check out the Kubernetes guide here
3 - Kubernetes DNS
Detailed information on the Kubernetes DNS name resolution component
Generally, Kubernetes DNS name resolution is configured automatically in Kubernetes mode by Dapr. There is no configuration needed to use Kubernetes DNS as your name resolution provider unless some overrides are necessary for the Kubernetes name resolution component.
In the scenario that an override is required, within a Dapr Configuration CRD, add a nameResolution
spec and set the component
field to "kubernetes"
. The other configuration fields can be set as needed in a configuration
map, as seen below.
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
nameResolution:
component: "kubernetes"
configuration:
clusterDomain: "cluster.local" # Mutually exclusive with the template field
template: "{{.ID}}-{{.Data.region}}.internal:{{.Port}}" # Mutually exclusive with the clusterDomain field
Behaviour
The component resolves target apps by using the Kubernetes cluster’s DNS provider. You can learn more in the Kubernetes docs.
Spec configuration fields
The configuration spec is fixed to v1.3.0 of the Consul API
Field | Required | Type | Details | Examples |
---|
clusterDomain | N | string | The cluster domain to be used for resolved addresses. This field is mutually exclusive with the template file. | cluster.local |
template | N | string | A template string to be parsed when addresses are resolved using text/template . The template will be populated by the fields in the ResolveRequest struct. This field is mutually exclusive with clusterDomain field. | {{.ID}}-{{.Data.region}}.{{.Namespace}}.internal:{{.Port}} |
4 - mDNS
Detailed information on the mDNS name resolution component
Multicast DNS (mDNS) is configured automatically in self-hosted mode by Dapr. There is no configuration needed to use mDNS as your name resolution provider.
Behaviour
The component resolves target apps by using the host system’s mDNS service. You can learn more about mDNS here.
Troubleshooting
In some cloud provider virtual networks, such as Microsoft Azure, mDNS is not available. Use an alternate provider such as HashiCorp Consul instead.
On some enterprise-managed systems, mDNS may be disabled on macOS if a network filter/proxy is configured. Check with your IT department if mDNS is disabled and you are unable to use service invocation locally.
Spec configuration fields
Not applicable, as mDNS is configured by Dapr when running in self-hosted mode.
5 - Nameformat
Detailed information on the NameFormat name resolution component
The Name Format name resolver provides a flexible way to resolve service names using a configurable format string with placeholders. This is useful in scenarios where you want to map service names to predictable DNS names following a specific pattern.
Consider using this name resolver if there is no specific name resolver available for your service registry, but your service registry can expose services via internal DNS names using predictable naming conventions.
Name resolution is configured via the Dapr Configuration.
Within the configuration YAML, set the spec.nameResolution.component
property to "nameformat"
, then pass configuration options in the spec.nameResolution.configuration
dictionary.
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
nameResolution:
component: "nameformat"
configuration:
format: "service-{appid}.default.svc.cluster.local" # Replace with your desired format pattern
Spec configuration fields
Field | Required | Details | Example |
---|
format | Y | The format string to use for name resolution. Must contain the {appid} placeholder which is replaced with the actual service name. | "service-{appid}.default.svc.cluster.local" |
Examples
When configured with format: "service-{appid}.default.svc.cluster.local"
, the resolver transforms service names as follows:
- Service ID “myapp” â “service-myapp.default.svc.cluster.local”
- Service ID “frontend” â “service-frontend.default.svc.cluster.local”
Notes
- Empty service IDs are not allowed and results in an error.
- The format string must be provided in the configuration
- The format string must contain at least one
{appid}
placeholder
6 - SQLite
Detailed information on the SQLite name resolution component
As an alternative to mDNS, the SQLite name resolution component can be used for running Dapr on single-node environments and for local development scenarios. Dapr sidecars that are part of the cluster store their information in a SQLite database on the local machine.
Note
This component is optimized to be used in scenarios where all Dapr instances are running on the same physical machine, where the database is accessed through the same, locally-mounted disk.
Using the SQLite nameresolver with a database file accessed over the network (including via SMB/NFS) can lead to issues such as data corruption, and is not supported.Name resolution is configured via the Dapr Configuration.
Within the Configuration YAML, set the spec.nameResolution.component
property to "sqlite"
, then pass configuration options in the spec.nameResolution.configuration
dictionary.
This is the basic example of a Configuration resource:
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
nameResolution:
component: "sqlite"
version: "v1"
configuration:
connectionString: "/home/user/.dapr/nr.db"
Spec configuration fields
When using the SQLite name resolver component, the spec.nameResolution.configuration
dictionary contains these options:
Field | Required | Type | Details | Examples |
---|
connectionString | Y | string | The connection string for the SQLite database. Normally, this is the path to a file on disk, relative to the current working directory, or absolute. | "nr.db" (relative to the working directory), "/home/user/.dapr/nr.db" |
updateInterval | N | Go duration (as a string ) | Interval for active Dapr sidecars to update their status in the database, which is used as healthcheck. Smaller intervals reduce the likelihood of stale data being returned if an application goes offline, but increase the load on the database. Must be at least 1s greater than timeout . Values with fractions of seconds are truncated (for example, 1500ms becomes 1s ). Default: 5s | "2s" |
timeout | N | Go duration (as a string ). Must be at least 1s. | Timeout for operations on the database. Integers are interpreted as number of seconds. Defaults to 1s | "2s" , 2 |
tableName | N | string | Name of the table where the data is stored. If the table does not exist, the table is created by Dapr. Defaults to hosts . | "hosts" |
metadataTableName | N | string | Name of the table used by Dapr to store metadata for the component. If the table does not exist, the table is created by Dapr. Defaults to metadata . | "metadata" |
cleanupInterval | N | Go duration (as a string ) | Interval to remove stale records from the database. Default: 1h (1 hour) | "10m" |
busyTimeout | N | Go duration (as a string ) | Interval to wait in case the SQLite database is currently busy serving another request, before returning a “database busy” error. This is an advanced setting.busyTimeout controls how locking works in SQLite. With SQLite, writes are exclusive, so every time any app is writing the database is locked. If another app tries to write, it waits up to busyTimeout before returning the “database busy” error. However the timeout setting controls the timeout for the entire operation. For example if the query “hangs”, after the database has acquired the lock (so after busy timeout is cleared), then timeout comes into effect. Default: 800ms (800 milliseconds) | "100ms" |
disableWAL | N | bool | If set to true, disables Write-Ahead Logging for journaling of the SQLite database. This is for advanced scenarios only | true , false |