Redis

要设置 Redis 状态储存,请创建一个类型为 的组件。 请参阅本指南,了解如何创建和应用状态存储配置。

TLS: 如果Redis 实例支持公开证书的TLS,它可以配置为启用或禁用 TLS truefals

Failover: When set to true enables the failover feature. The redisHost should be the sentinel host address. See

Warning

以上示例将密钥明文存储, 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. If you already have a Redis store, move on to the Configuration section.

We can use to quickly create a Redis instance in our Kubernetes cluster. 这种方法需要安装Helm

  1. 安装 Redis 到你的集群: 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. 执行kubectl get pods来查看现在正在集群中运行的Redis容器。

  3. Add as the redisHost in your file. 例如:

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

    • Windows:执行kubectl get secret --namespace default redis -o jsonpath="{.data.redis-password}" > encoded.b64,这将创建一个有你的加密后密码的文件。 接下来,执行certutil -decode encoded.b64 password.txt,它将把你的redis密码放在一个名为password.txt的文本文件中。 复制密码,删除这两个文件。

    Add this password as the redisPassword value in your redis.yaml file. 例如:

Note: this approach requires having an Azure Subscription.

  1. Fill out necessary information and check the “Unblock port 6379” box, which will allow us to persist state without SSL.
  2. 点击“创建”来启动您的 Redis 实例的部署。
  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 redisPassword 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

Note

作为dapr init命令的一部分,Dapr CLI会在自托管模式下自动部署本地redis实例。