Files
k3s/011-skills/005-redis-policy.md
2026-02-05 00:11:05 +08:00

29 lines
1.1 KiB
Markdown
Raw 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.
# Redis的内存限额、持久化逻辑
# 中间件技能Redis 独立 Pod 持久化策略
## 1. 部署模式
- **控制器类型**: `StatefulSet` (保证 Pod 名称固定为 redis-0利于挂载持久卷)
- **命名空间**: `middleware`
- **端口**: `6379`
## 2. 存储与持久化 (关键)
- **存储驱动**: Longhorn (提供跨节点漂移能力)
- **PVC 名称**: `redis-data-pvc`
- **挂载路径**: `/data`
- **持久化配置**:
- `appendonly: yes` (AOF模式每秒刷盘一次确保数据安全性)
- `save: 900 1` (RDB快照作为辅助)
## 3. 资源限制 (Resource Quota)
为了防止内存溢出导致 K3s 节点崩溃,设定以下硬限额:
- **Memory Request/Limit**: `512Mi` / `1Gi`
- **Redis Maxmemory**: `768mb` (保留部分内存给系统,防止 OOM)
- **CPU Request/Limit**: `100m` / `500m`
## 4. 安全策略
- **认证**: 必须通过 `requirepass` 设置高强度密码。
- **配置注入**: 密码应通过 `Secret` 对象注入,配置文件通过 `ConfigMap` 挂载。
## 5. 灾备关联
- **Longhorn 备份**: 关联 `004-longhorn-s3.md`,每 24 小时执行一次卷快照并上传至 S3。