The documentation you are viewing is for Dapr v0.11 which is an older version of Dapr. For up-to-date documentation, see the latest version.

etcd

Detailed information on the etcd state store component

Setup an etcd state store


You can run etcd locally using Docker:

docker run -d --name etcd bitnami/etcd

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


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

helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
helm install etcd incubator/etcd

This will install etcd into the default namespace. To interact with etcd, find the service with: kubectl get svc etcd-etcd.

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

etcd-etcd.default.svc.cluster.local:2379

Create a Dapr component

The next step is to create a Dapr component for etcd.

Create the following YAML file named etcd.yaml:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: <NAME>
  namespace: <NAMESPACE>
spec:
  type: state.etcd
  version: v1
  metadata:
  - name: endpoints
    value: <REPLACE-WITH-COMMA-DELIMITED-ENDPOINTS> # Required. Example: "etcd-etcd.default.svc.cluster.local:2379"
  - name: dialTimeout
    value: <REPLACE-WITH-DIAL-TIMEOUT> # Required. Example: "5s"
  - name: operationTimeout
    value: <REPLACE-WITH-OPERATION-TIMEOUT> # Optional. default: "10S"

Apply the configuration

In Kubernetes

To apply the etcd state store to Kubernetes, use the kubectl CLI:

kubectl apply -f etcd.yaml

Running locally

To run locally, create a components dir containing the YAML file and provide the path to the dapr run command with the flag --components-path.

Last modified July 7, 2022: update nav bar v0.11 (#2633) (b309d3d)