This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

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:

HeaderDescriptionExample
StatusComponent certification statusAlpha
Beta
Stable
Component versionThe version of the componentv1
Since runtime versionThe version of the Dapr runtime when the component status was set or updated1.11

Generic

ComponentStatusComponent versionSince runtime version
HashiCorp ConsulAlphav11.2
NameFormatAlphav11.16
SQLiteAlphav11.13

Kubernetes

ComponentStatusComponent versionSince runtime version
KubernetesStablev11.0

Self-Hosted

ComponentStatusComponent versionSince runtime version
mDNSStablev11.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.

Configuration format

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:

  1. Environment Variables:

    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
    • AWS_SESSION_TOKEN (optional)
  2. IAM Roles:

    • When running on AWS (EKS, EC2, etc.), the component can use IAM roles
  3. 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

FieldRequiredTypeDefaultDescription
namespaceNameOne of namespaceName or namespaceIdstring""The name of your AWS CloudMap namespace
namespaceIdOne of namespaceName or namespaceIdstring""The ID of your AWS CloudMap namespace
regionNstring""AWS region. If not provided, will be determined from environment or instance metadata
endpointNstring""Custom endpoint for AWS CloudMap API. Useful for testing with LocalStack
defaultDaprPortNnumber3500Default 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:

  1. Required: One of these address attributes:

    • AWS_INSTANCE_IPV4: IPv4 address of the instance
    • AWS_INSTANCE_IPV6: IPv6 address of the instance
    • AWS_INSTANCE_CNAME: Hostname of the instance
  2. 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

Configuration format

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

FieldRequiredTypeDetailsExamples
ClientN*api.ConfigConfigures 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:850010.0.4.4:8500
QueryOptionsN*api.QueryOptionsConfigures query used for resolving healthy services, if blank it will default to UseCache:trueUseCache: false, Datacenter: "myDC"
ChecksN[]*api.AgentServiceCheckConfigures health checks if/when registering. If blank it will default to a single health check on the Dapr sidecar health endpointSee sample configs
TagsN[]stringConfigures any tags to include if/when registering services- "dapr"
MetaNmap[string]stringConfigures any additional metadata to include if/when registering servicesDAPR_METRICS_PORT: "${DAPR_METRICS_PORT}"
DaprPortMetaKeyNstringThe 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"
SelfRegisterNboolControls 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 falsetrue
AdvancedRegistrationN*api.AgentServiceRegistrationGives 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

Configuration format

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

FieldRequiredTypeDetailsExamples
clusterDomainNstringThe cluster domain to be used for resolved addresses. This field is mutually exclusive with the template file.cluster.local
templateNstringA 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

Configuration format

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.

Configuration Format

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

FieldRequiredDetailsExample
formatYThe 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.

Configuration format

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:

FieldRequiredTypeDetailsExamples
connectionStringYstringThe 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"
updateIntervalNGo 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"
timeoutNGo 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
tableNameNstringName of the table where the data is stored. If the table does not exist, the table is created by Dapr. Defaults to hosts."hosts"
metadataTableNameNstringName 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"
cleanupIntervalNGo duration (as a string)Interval to remove stale records from the database. Default: 1h (1 hour)"10m"
busyTimeoutNGo 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"
disableWALNboolIf set to true, disables Write-Ahead Logging for journaling of the SQLite database. This is for advanced scenarios onlytrue, false