Redis
To setup Redis configuration store create a component of type . See this guide on how to create and apply a configuration store configuration.
Warning
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.
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
You can use to quickly create a Redis instance in our Kubernetes cluster. This approach requires Installing Helm.
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.Next, 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 creates 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.Linux/MacOS: Run
kubectl get secret --namespace default redis -o jsonpath="{.data.redis-password}" | base64 --decode
and copy the outputted password.
Add this password as the
redisPassword
value in your file. For example:
Note: this approach requires having an Azure Subscription.
Start the Azure Cache for Redis creation flow. Log in if necessary.
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 resource’s “Overview” and copy “Host name”.
- For your access key: navigate to “Settings” > “Access Keys” to copy and save your key.
Add your key and your host to a
redis.yaml
file that Dapr can apply to your cluster.- If you’re running a sample, add the host and key to the provided
redis.yaml
. - If you’re creating a project from the ground up, create a
redis.yaml
file as specified in .
Set the
redisHost
key to and theredisPassword
key to the key you saved earlier.Note: In a production-grade application, follow secret management instructions to securely manage your secrets.
- If you’re running a sample, add the host and key to the provided