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.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Configuration
  3. metadata:
  4. name: appconfig
  5. spec:
  6. nameResolution:
  7. component: "kubernetes"
  8. configuration:
  9. clusterDomain: "cluster.local" # Mutually exclusive with the template field
  10. 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

FieldRequiredTypeDetails示例
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}}