HashiCorp Consul

Detailed information on the HashiCorp Consul state store component

Component format

To setup Hashicorp Consul state store create a component of type state.consul. See this guide on how to create and apply a state store configuration.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. spec:
  6. type: state.consul
  7. version: v1
  8. metadata:
  9. - name: datacenter
  10. value: <REPLACE-WITH-DATA-CENTER> # Required. Example: dc1
  11. - name: httpAddr
  12. value: <REPLACE-WITH-CONSUL-HTTP-ADDRESS> # Required. Example: "consul.default.svc.cluster.local:8500"
  13. - name: aclToken
  14. value: <REPLACE-WITH-ACL-TOKEN> # Optional. default: ""
  15. - name: scheme
  16. value: <REPLACE-WITH-SCHEME> # Optional. default: "http"
  17. - name: keyPrefixPath
  18. value: <REPLACE-WITH-TABLE> # Optional. default: ""

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.

Spec metadata fields

FieldRequiredDetailsExample
datacenterYDatacenter to use“dc1”
httpAddrYAddress of the Consul server“consul.default.svc.cluster.local:8500”
aclTokenNPer Request ACL Token. Default is “”“token”
schemeNScheme is the URI scheme for the Consul server. Default is “http”“http”
keyPrefixPathNKey prefix path in Consul. Default is “”“dapr”

Setup HashiCorp Consul

You can run Consul locally using Docker:

  1. docker run -d --name=dev-consul -e CONSUL_BIND_INTERFACE=eth0 consul

You can then interact with the server using localhost:8500.

The easiest way to install Consul on Kubernetes is by using the Helm chart:

  1. helm install consul stable/consul

This installs Consul into the default namespace. To interact with Consul, find the service with: kubectl get svc consul.

For example, if installing using the example above, the Consul host address would be:

consul.default.svc.cluster.local:8500

Last modified October 12, 2023: Update config.toml (#3826) (0ffc2e7)