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
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.
Run
kubectl get pods
to see the Redis containers now running in your cluster.Add
redis-master:6379
as theredisHost
in your redis.yaml file. For example: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, runcertutil -decode encoded.b64 password.txt
, which will put your redis password in a text file calledpassword.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.
- Open this link to start the Azure Cache for Redis creation flow. Log in if necessary.
- Click “Create” to kickoff deployment of your Redis instance.
- 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.
- 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 providedredis.yaml
. If you’re creating a project from the ground up, you’ll create aredis.yaml
file as specified in . Set theredisHost
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.
- Read this guide for instructions on configuring state store components