Redis

To setup Redis state store create a component of type . See on how to create and apply a state store configuration.

Warning

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

If you wish to use Redis as an actor store, append the following to the yaml.

Dapr can use any Redis instance - containerized, running on your local dev machine, or a managed cloud service.

A Redis instance is automatically created as a Docker container when you run dapr init

  1. Install Redis into your cluster. Note that we’re explicitly setting an image tag to get a version greater than 5, which is what Dapr’ pub/sub functionality requires. If you’re intending on using Redis as just a state store (and not for pub/sub), you do not have to set the image version.

  2. Run kubectl get pods to see the Redis containers now running in your cluster.

  3. Add redis-master:6379 as the redisHost in your redis.yaml file. For example:

  4. Next, we’ll get the Redis password, which is slightly different depending on the OS we’re using:

    • Windows: Run kubectl get secret --namespace default redis -o jsonpath="{.data.redis-password}" > encoded.b64, which will create a file with your encoded password. Next, run certutil -decode encoded.b64 password.txt, which will put your redis password in a text file called password.txt. Copy the password and delete the two files.

    Add this password as the redisPassword value in your file. For example:

Note: this approach requires having an Azure Subscription.

  1. Open this link to start the Azure Cache for Redis creation flow. Log in if necessary.
  2. Click “Create” to kickoff deployment of your Redis instance.
  3. Once your instance is created, you’ll need to grab the Host name (FQDN) and your access key.
    • for the Host name navigate to the resources “Overview” and copy “Host name”
    • for your access key navigate to “Access Keys” under “Settings” and copy your key.
  4. Finally, we need to add our key and our host to a redis.yaml file that Dapr can apply to our cluster. If you’re running a sample, you’ll add the host and key to the provided redis.yaml. If you’re creating a project from the ground up, you’ll create a redis.yaml file as specified in . Set the redisHost key to [HOST NAME FROM PREVIOUS STEP]:6379 and the key to the key you copied in step 4. Note: In a production-grade application, follow secret management instructions to securely manage your secrets.

GCP Cloud MemoryStore

  • Read this guide for instructions on configuring state store components