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
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" |
When configured with format: "service-{appid}.default.svc.cluster.local"
, the resolver transforms service names as follows:
{appid}
placeholder