istio.io/content/zh/faq/applications/redis.md

27 lines
1013 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 我可以在 Istio 网格内运行 Redis 吗?
description: 如何使用 Istio 运行 Redis。
weight: 50
keywords: [redis]
---
与在 Istio 服务网格中部署的其他服务类似Redis 实例需要监听 `localhost` (`127.0.0.1`)。每个 Redis 从属实例都应声明一个地址,主服务器可以使用该地址来访问它,但是,该地址不能是 `localhost` (`127.0.0.1`)。
使用 Redis 配置参数 `replica-announce-ip` 来公布正确的地址。例如,使用以下步骤将 `replica-announce-ip` 设置为每个 Redis 从属实例的 IP 地址:
通过从属 `StatefulSet``env` 小节中定义的环境变量传递 Pod IP 地址:
{{< text yaml >}}
- name: "POD_IP"
valueFrom:
fieldRef:
fieldPath: status.podIP
{{< /text >}}
另外,在 `command` 小节下添加以下内容:
{{< text yaml >}}
echo "" >> /opt/bitnami/redis/etc/replica.conf
echo "replica-announce-ip $POD_IP" >> /opt/bitnami/redis/etc/replica.conf
{{< /text >}}