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.

Zookeeper

Detailed information on the Zookeeper state store component

Setup a Zookeeper state store


You can run Zookeeper locally using Docker:

docker run --name some-zookeeper --restart always -d zookeeper

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


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

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

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

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

zookeeper.default.svc.cluster.local:2181

Create a Dapr component

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

Create the following YAML file named zookeeper.yaml:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: <NAME>
  namespace: <NAMESPACE>
spec:
  type: state.zookeeper
  version: v1
  metadata:
  - name: servers
    value: <REPLACE-WITH-COMMA-DELIMITED-SERVERS> # Required. Example: "zookeeper.default.svc.cluster.local:2181"
  - name: sessionTimeout
    value: <REPLACE-WITH-SESSION-TIMEOUT> # Required. Example: "5s"
  - name: maxBufferSize
    value: <REPLACE-WITH-MAX-BUFFER-SIZE> # Optional. default: "1048576"
  - name: maxConnBufferSize
    value: <REPLACE-WITH-MAX-CONN-BUFFER-SIZE> # Optional. default: "1048576"
  - name: keyPrefixPath
    value: <REPLACE-WITH-KEY-PREFIX-PATH> # Optional.

Apply the configuration

In Kubernetes

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

kubectl apply -f zookeeper.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)