Cassandra

Detailed information on the Cassandra state store component

Component format

To setup Cassandra state store create a component of type state.cassandra. 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.cassandra
  7. version: v1
  8. metadata:
  9. - name: hosts
  10. value: <REPLACE-WITH-COMMA-DELIMITED-HOSTS> # Required. Example: cassandra.cassandra.svc.cluster.local
  11. - name: username
  12. value: <REPLACE-WITH-PASSWORD> # Optional. default: ""
  13. - name: password
  14. value: <REPLACE-WITH-PASSWORD> # Optional. default: ""
  15. - name: consistency
  16. value: <REPLACE-WITH-CONSISTENCY> # Optional. default: "All"
  17. - name: table
  18. value: <REPLACE-WITH-TABLE> # Optional. default: "items"
  19. - name: keyspace
  20. value: <REPLACE-WITH-KEYSPACE> # Optional. default: "dapr"
  21. - name: protoVersion
  22. value: <REPLACE-WITH-PROTO-VERSION> # Optional. default: "4"
  23. - name: replicationFactor
  24. value: <REPLACE-WITH-REPLICATION-FACTOR> # Optional. default: "1"

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
hostsYComma separated value of the hosts“cassandra.cassandra.svc.cluster.local”.
portNPort for communication. Default “9042”“9042”
usernameYThe username of database user. No default“user”
passwordYThe password for the user“password”
consistencyNThe consistency values“All”, “Quorum”
tableNTable name. Defaults to “items”“items”, “tab”
keyspaceNThe cassandra keyspace to use. Defaults to “dapr”“dapr”
protoVersionNThe proto version for the client. Defaults to “4”“3”, “4”
replicationFactorNThe replication factor for the calls. Defaults to “1”“3”

Setup Cassandra

You can run Cassandra locally with the Datastax Docker image:

  1. docker run -e DS_LICENSE=accept --memory 4g --name my-dse -d datastax/dse-server -g -s -k

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

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

  1. kubectl create namespace cassandra
  2. helm install cassandra incubator/cassandra --namespace cassandra

This installs Cassandra into the cassandra namespace by default. To interact with Cassandra, find the service with: kubectl get svc -n cassandra.

For example, if installing using the example above, the Cassandra DNS would be:

cassandra.cassandra.svc.cluster.local

Last modified July 27, 2022: Remove namespace element from component examples (#2647) (ff9de5c8)