redis

Deploy Redis in-memory data store - supports Docker, Kubernetes, package manager, or source build

Recipaie - 部署配方

描述如何部署此服务的模板。

原始 JSON
{
  "$schema": "https://recipaie.com/schemas/recipaie.schema.json",
  "name": "redis",
  "version": "1.0.0",
  "description": "Deploy Redis in-memory data store - supports Docker, Kubernetes, package manager, or source build",
  "prerequisites": [
    "One of: Docker, Kubernetes cluster, Linux package manager (apt/yum), or build tools for source compilation",
    "Sufficient memory for your dataset (Redis keeps data in RAM)",
    "Persistent storage if data durability is required"
  ],
  "steps": [
    {
      "order": 1,
      "what": "Choose Redis variant and deployment method",
      "why": "Redis comes in multiple flavors with different features",
      "when": "Before installation",
      "how": "Decide: (1) Standard Redis - basic key-value, (2) Redis Stack - includes RediSearch, RedisJSON, RedisGraph, (3) Redis Cluster - for horizontal scaling. Then choose deployment: Docker, K8s, package manager, or source build",
      "verify": "Variant and method documented",
      "comments": [
        "Redis Stack recommended if you need search or JSON support",
        "Standard Redis is lighter (~5MB) vs Redis Stack (~50MB)",
        "For production: always configure persistence (RDB/AOF)"
      ]
    },
    {
      "order": 2,
      "what": "Create data directory for persistence",
      "why": "Redis can persist data to disk for durability",
      "when": "If data persistence is required",
      "skip_if": "Using ephemeral/cache-only Redis, or directory already exists",
      "how": "Create directory with appropriate permissions: mkdir -p /var/lib/redis && chown redis:redis /var/lib/redis (Linux), or use named volume (Docker), or PersistentVolumeClaim (K8s)",
      "verify": "Directory exists and is writable by Redis process",
      "comments": [
        "Path varies by environment - /var/lib/redis is Linux convention",
        "Docker: use named volumes for persistence across container restarts",
        "K8s: use PVC with appropriate storage class"
      ]
    },
    {
      "order": 3,
      "what": "Install or deploy Redis",
      "why": "Get Redis running in your environment",
      "when": "After prerequisites are ready",
      "skip_if": "Redis already installed and running at target version",
      "how": "Choose method: (Docker) docker run -d --name redis -p 6379:6379 redis:7-alpine, (Docker Stack) redis:7-alpine with volume mounts, (K8s) use Bitnami Redis Helm chart, (Ubuntu/Debian) apt install redis-server, (RHEL/CentOS) dnf install redis, (macOS) brew install redis, (Source) download from redis.io and make install",
      "verify": "redis-cli ping returns PONG",
      "comments": [
        "Use redis:7-alpine for minimal image size (~30MB)",
        "For Redis Stack: redis/redis-stack:latest or redis/redis-stack-server:latest",
        "Production: always set maxmemory and eviction policy"
      ]
    },
    {
      "order": 4,
      "what": "Configure Redis settings",
      "why": "Default settings are for development - production needs tuning",
      "when": "Before exposing to production traffic",
      "skip_if": "Using Redis only for development/testing",
      "how": "Edit redis.conf or pass config via command line: Set maxmemory (e.g., 2gb), maxmemory-policy (e.g., allkeys-lru), save intervals for RDB, appendonly yes for AOF, requirepass for authentication",
      "verify": "redis-cli CONFIG GET maxmemory shows expected value",
      "comments": [
        "Docker: mount custom redis.conf or use --redis-server args",
        "K8s: use ConfigMap for redis.conf",
        "Critical settings: maxmemory, persistence, authentication"
      ]
    },
    {
      "order": 5,
      "what": "Enable authentication",
      "why": "Protect Redis from unauthorized access",
      "when": "If Redis is network-accessible (not just localhost)",
      "skip_if": "Redis bound to localhost only and not exposed externally",
      "how": "Set password: redis-cli CONFIG SET requirepass 'your-secure-password', or in redis.conf: requirepass your-secure-password",
      "verify": "redis-cli AUTH your-secure-password returns OK, unauthenticated commands fail with NOAUTH",
      "comments": [
        "Redis 6+ supports ACLs for fine-grained permissions",
        "Never expose Redis to public internet without authentication",
        "Use strong passwords - Redis is fast at trying passwords too"
      ]
    },
    {
      "order": 6,
      "what": "Verify Redis is operational",
      "why": "Confirm the deployment is working correctly",
      "when": "After deployment and configuration",
      "how": "Test basic operations: SET testkey testvalue, GET testkey, DEL testkey. Check memory: INFO memory. Check persistence: LASTSAVE",
      "verify": "All operations succeed, memory usage within limits"
    }
  ],
  "step_count": 6
}
版本: 1.0.0
步骤数: 6

前置条件

步骤

1 Choose Redis variant and deployment method
为什么
Redis comes in multiple flavors with different features
何时做
Before installation
如何做
Decide: (1) Standard Redis - basic key-value, (2) Redis Stack - includes RediSearch, RedisJSON, RedisGraph, (3) Redis Cluster - for horizontal scaling. Then choose deployment: Docker, K8s, package manager, or source build
验证
Variant and method documented
备注
  • Redis Stack recommended if you need search or JSON support
  • Standard Redis is lighter (~5MB) vs Redis Stack (~50MB)
  • For production: always configure persistence (RDB/AOF)
2 Create data directory for persistence
为什么
Redis can persist data to disk for durability
何时做
If data persistence is required
何时跳过
Using ephemeral/cache-only Redis, or directory already exists
如何做
Create directory with appropriate permissions: mkdir -p /var/lib/redis && chown redis:redis /var/lib/redis (Linux), or use named volume (Docker), or PersistentVolumeClaim (K8s)
验证
Directory exists and is writable by Redis process
备注
  • Path varies by environment - /var/lib/redis is Linux convention
  • Docker: use named volumes for persistence across container restarts
  • K8s: use PVC with appropriate storage class
3 Install or deploy Redis
为什么
Get Redis running in your environment
何时做
After prerequisites are ready
何时跳过
Redis already installed and running at target version
如何做
Choose method: (Docker) docker run -d --name redis -p 6379:6379 redis:7-alpine, (Docker Stack) redis:7-alpine with volume mounts, (K8s) use Bitnami Redis Helm chart, (Ubuntu/Debian) apt install redis-server, (RHEL/CentOS) dnf install redis, (macOS) brew install redis, (Source) download from redis.io and make install
验证
redis-cli ping returns PONG
备注
  • Use redis:7-alpine for minimal image size (~30MB)
  • For Redis Stack: redis/redis-stack:latest or redis/redis-stack-server:latest
  • Production: always set maxmemory and eviction policy
4 Configure Redis settings
为什么
Default settings are for development - production needs tuning
何时做
Before exposing to production traffic
何时跳过
Using Redis only for development/testing
如何做
Edit redis.conf or pass config via command line: Set maxmemory (e.g., 2gb), maxmemory-policy (e.g., allkeys-lru), save intervals for RDB, appendonly yes for AOF, requirepass for authentication
验证
redis-cli CONFIG GET maxmemory shows expected value
备注
  • Docker: mount custom redis.conf or use --redis-server args
  • K8s: use ConfigMap for redis.conf
  • Critical settings: maxmemory, persistence, authentication
5 Enable authentication
为什么
Protect Redis from unauthorized access
何时做
If Redis is network-accessible (not just localhost)
何时跳过
Redis bound to localhost only and not exposed externally
如何做
Set password: redis-cli CONFIG SET requirepass 'your-secure-password', or in redis.conf: requirepass your-secure-password
验证
redis-cli AUTH your-secure-password returns OK, unauthenticated commands fail with NOAUTH
备注
  • Redis 6+ supports ACLs for fine-grained permissions
  • Never expose Redis to public internet without authentication
  • Use strong passwords - Redis is fast at trying passwords too
6 Verify Redis is operational
为什么
Confirm the deployment is working correctly
何时做
After deployment and configuration
如何做
Test basic operations: SET testkey testvalue, GET testkey, DEL testkey. Check memory: INFO memory. Check persistence: LASTSAVE
验证
All operations succeed, memory usage within limits

Prodaie - 执行记录

AI 在不同环境中执行这份配方时发生了什么。

关键区别: 每一步都会增加

success

(bool)和

details

(string)字段,用于记录实际发生了什么。

原始 JSON
{
  "$schema": "https://recipaie.com/schemas/prodaie.schema.json",
  "name": "redis",
  "description": "Deployment record showing Redis in different environments: Docker, Kubernetes, and package manager",
  "locations": [
    {
      "path": "dev-laptop (Docker)",
      "description": "Local development using Docker",
      "status": "complete",
      "step_count": 6,
      "steps": [
        {
          "order": 1,
          "what": "Choose Redis variant and deployment method",
          "why": "Redis comes in multiple flavors with different features",
          "when": "Before installation",
          "how": "Decide variant and deployment method",
          "verify": "Variant and method documented",
          "success": true,
          "details": "chose Redis Stack for RediSearch support, Docker for isolation"
        },
        {
          "order": 2,
          "what": "Create data directory for persistence",
          "why": "Redis can persist data to disk for durability",
          "when": "If data persistence is required",
          "skip_if": "Using ephemeral Redis",
          "how": "Create named Docker volume",
          "verify": "Volume exists",
          "success": true,
          "details": "created volume: docker volume create redis-dev-data"
        },
        {
          "order": 3,
          "what": "Install or deploy Redis",
          "why": "Get Redis running in your environment",
          "when": "After prerequisites are ready",
          "skip_if": "Redis already running at target version",
          "how": "docker run with Redis Stack image",
          "verify": "redis-cli ping returns PONG",
          "success": true,
          "details": "docker run -d --name redis-dev -p 6379:6379 -v redis-dev-data:/data redis/redis-stack:latest"
        },
        {
          "order": 4,
          "what": "Configure Redis settings",
          "why": "Default settings are for development",
          "when": "Before exposing to production traffic",
          "skip_if": "Using Redis only for development",
          "how": "Set maxmemory and persistence",
          "verify": "CONFIG GET maxmemory shows value",
          "success": true,
          "details": "development use only, defaults are fine"
        },
        {
          "order": 5,
          "what": "Enable authentication",
          "why": "Protect Redis from unauthorized access",
          "when": "If Redis is network-accessible",
          "skip_if": "Redis bound to localhost only",
          "how": "Set requirepass",
          "verify": "Unauthenticated commands fail",
          "success": true,
          "details": "bound to localhost only via -p 127.0.0.1:6379:6379"
        },
        {
          "order": 6,
          "what": "Verify Redis is operational",
          "why": "Confirm the deployment is working correctly",
          "when": "After deployment and configuration",
          "how": "Test basic operations",
          "verify": "All operations succeed",
          "success": true,
          "details": "SET/GET/DEL working, FT._LIST confirms RediSearch loaded"
        }
      ]
    },
    {
      "path": "prod-cluster (Kubernetes)",
      "description": "Production Kubernetes cluster with HA",
      "status": "complete",
      "step_count": 6,
      "steps": [
        {
          "order": 1,
          "what": "Choose Redis variant and deployment method",
          "why": "Redis comes in multiple flavors",
          "when": "Before installation",
          "how": "Decide variant and deployment",
          "verify": "Variant and method documented",
          "success": true,
          "details": "chose standard Redis 7 with Sentinel for HA, Bitnami Helm chart"
        },
        {
          "order": 2,
          "what": "Create data directory for persistence",
          "why": "Redis can persist data to disk",
          "when": "If data persistence required",
          "skip_if": "Using PVC in Helm chart",
          "how": "Create PersistentVolumeClaim",
          "verify": "PVC bound",
          "success": true,
          "details": "Bitnami chart creates PVCs automatically"
        },
        {
          "order": 3,
          "what": "Install or deploy Redis",
          "why": "Get Redis running",
          "when": "After prerequisites ready",
          "skip_if": "Redis already running at target version",
          "how": "helm install redis bitnami/redis --set replica.replicaCount=3",
          "verify": "kubectl get pods shows all replicas Running",
          "success": true,
          "details": "1 master + 3 replicas deployed in redis namespace"
        },
        {
          "order": 4,
          "what": "Configure Redis settings",
          "why": "Production needs tuning",
          "when": "Before production traffic",
          "skip_if": "Using Helm values for config",
          "how": "Configure via Helm values",
          "verify": "CONFIG GET maxmemory shows expected",
          "success": true,
          "details": "set maxmemory=4gb, maxmemory-policy=allkeys-lru via values.yaml"
        },
        {
          "order": 5,
          "what": "Enable authentication",
          "why": "Protect Redis from unauthorized access",
          "when": "If network-accessible",
          "skip_if": "Password set via Helm",
          "how": "Helm chart creates Secret with password",
          "verify": "AUTH required to connect",
          "success": true,
          "details": "password in k8s secret redis-password, injected via REDIS_PASSWORD env"
        },
        {
          "order": 6,
          "what": "Verify Redis is operational",
          "why": "Confirm deployment works",
          "when": "After configuration",
          "how": "Port-forward and test",
          "verify": "All operations succeed",
          "success": true,
          "details": "kubectl port-forward svc/redis-master 6379:6379, all tests passed"
        }
      ]
    },
    {
      "path": "legacy-server (Ubuntu package)",
      "description": "Legacy Ubuntu server using apt package",
      "status": "complete",
      "step_count": 6,
      "steps": [
        {
          "order": 1,
          "what": "Choose Redis variant and deployment method",
          "why": "Redis comes in multiple flavors",
          "when": "Before installation",
          "how": "Decide variant and deployment",
          "verify": "Method documented",
          "success": true,
          "details": "chose standard Redis from Ubuntu repos, systemd for management"
        },
        {
          "order": 2,
          "what": "Create data directory for persistence",
          "why": "Redis needs persistent storage",
          "when": "If data persistence required",
          "skip_if": "Using default /var/lib/redis",
          "how": "Use default package paths",
          "verify": "Directory exists",
          "success": true,
          "details": "apt creates /var/lib/redis automatically"
        },
        {
          "order": 3,
          "what": "Install or deploy Redis",
          "why": "Get Redis running",
          "when": "After prerequisites ready",
          "skip_if": "Redis already at target version",
          "how": "apt install redis-server",
          "verify": "redis-cli ping returns PONG",
          "success": true,
          "details": "apt update && apt install -y redis-server, version 7.0.15"
        },
        {
          "order": 4,
          "what": "Configure Redis settings",
          "why": "Production needs tuning",
          "when": "Before production traffic",
          "skip_if": "Development only",
          "how": "Edit /etc/redis/redis.conf",
          "verify": "CONFIG GET maxmemory shows value",
          "success": true,
          "details": "set maxmemory 2gb, appendonly yes in /etc/redis/redis.conf"
        },
        {
          "order": 5,
          "what": "Enable authentication",
          "why": "Protect Redis",
          "when": "If network-accessible",
          "skip_if": "Localhost only",
          "how": "Set requirepass in config",
          "verify": "AUTH required",
          "success": true,
          "details": "added requirepass to /etc/redis/redis.conf, restarted service"
        },
        {
          "order": 6,
          "what": "Verify Redis is operational",
          "why": "Confirm deployment",
          "when": "After configuration",
          "how": "Test with redis-cli",
          "verify": "All operations succeed",
          "success": true,
          "details": "systemctl status redis-server shows active, SET/GET working"
        }
      ]
    }
  ]
}
安装位置: 3

安装位置

dev-laptop (Docker) complete

Local development using Docker

步骤数: 6
1 Choose Redis variant and deployment method
为什么
Redis comes in multiple flavors with different features
何时做
Before installation
如何做
Decide variant and deployment method
验证
Variant and method documented
结果
chose Redis Stack for RediSearch support, Docker for isolation
2 Create data directory for persistence
为什么
Redis can persist data to disk for durability
何时做
If data persistence is required
何时跳过
Using ephemeral Redis
如何做
Create named Docker volume
验证
Volume exists
结果
created volume: docker volume create redis-dev-data
3 Install or deploy Redis
为什么
Get Redis running in your environment
何时做
After prerequisites are ready
何时跳过
Redis already running at target version
如何做
docker run with Redis Stack image
验证
redis-cli ping returns PONG
结果
docker run -d --name redis-dev -p 6379:6379 -v redis-dev-data:/data redis/redis-stack:latest
4 Configure Redis settings
为什么
Default settings are for development
何时做
Before exposing to production traffic
何时跳过
Using Redis only for development
如何做
Set maxmemory and persistence
验证
CONFIG GET maxmemory shows value
结果
development use only, defaults are fine
5 Enable authentication
为什么
Protect Redis from unauthorized access
何时做
If Redis is network-accessible
何时跳过
Redis bound to localhost only
如何做
Set requirepass
验证
Unauthenticated commands fail
结果
bound to localhost only via -p 127.0.0.1:6379:6379
6 Verify Redis is operational
为什么
Confirm the deployment is working correctly
何时做
After deployment and configuration
如何做
Test basic operations
验证
All operations succeed
结果
SET/GET/DEL working, FT._LIST confirms RediSearch loaded
prod-cluster (Kubernetes) complete

Production Kubernetes cluster with HA

步骤数: 6
1 Choose Redis variant and deployment method
为什么
Redis comes in multiple flavors
何时做
Before installation
如何做
Decide variant and deployment
验证
Variant and method documented
结果
chose standard Redis 7 with Sentinel for HA, Bitnami Helm chart
2 Create data directory for persistence
为什么
Redis can persist data to disk
何时做
If data persistence required
何时跳过
Using PVC in Helm chart
如何做
Create PersistentVolumeClaim
验证
PVC bound
结果
Bitnami chart creates PVCs automatically
3 Install or deploy Redis
为什么
Get Redis running
何时做
After prerequisites ready
何时跳过
Redis already running at target version
如何做
helm install redis bitnami/redis --set replica.replicaCount=3
验证
kubectl get pods shows all replicas Running
结果
1 master + 3 replicas deployed in redis namespace
4 Configure Redis settings
为什么
Production needs tuning
何时做
Before production traffic
何时跳过
Using Helm values for config
如何做
Configure via Helm values
验证
CONFIG GET maxmemory shows expected
结果
set maxmemory=4gb, maxmemory-policy=allkeys-lru via values.yaml
5 Enable authentication
为什么
Protect Redis from unauthorized access
何时做
If network-accessible
何时跳过
Password set via Helm
如何做
Helm chart creates Secret with password
验证
AUTH required to connect
结果
password in k8s secret redis-password, injected via REDIS_PASSWORD env
6 Verify Redis is operational
为什么
Confirm deployment works
何时做
After configuration
如何做
Port-forward and test
验证
All operations succeed
结果
kubectl port-forward svc/redis-master 6379:6379, all tests passed
legacy-server (Ubuntu package) complete

Legacy Ubuntu server using apt package

步骤数: 6
1 Choose Redis variant and deployment method
为什么
Redis comes in multiple flavors
何时做
Before installation
如何做
Decide variant and deployment
验证
Method documented
结果
chose standard Redis from Ubuntu repos, systemd for management
2 Create data directory for persistence
为什么
Redis needs persistent storage
何时做
If data persistence required
何时跳过
Using default /var/lib/redis
如何做
Use default package paths
验证
Directory exists
结果
apt creates /var/lib/redis automatically
3 Install or deploy Redis
为什么
Get Redis running
何时做
After prerequisites ready
何时跳过
Redis already at target version
如何做
apt install redis-server
验证
redis-cli ping returns PONG
结果
apt update && apt install -y redis-server, version 7.0.15
4 Configure Redis settings
为什么
Production needs tuning
何时做
Before production traffic
何时跳过
Development only
如何做
Edit /etc/redis/redis.conf
验证
CONFIG GET maxmemory shows value
结果
set maxmemory 2gb, appendonly yes in /etc/redis/redis.conf
5 Enable authentication
为什么
Protect Redis
何时做
If network-accessible
何时跳过
Localhost only
如何做
Set requirepass in config
验证
AUTH required
结果
added requirepass to /etc/redis/redis.conf, restarted service
6 Verify Redis is operational
为什么
Confirm deployment
何时做
After configuration
如何做
Test with redis-cli
验证
All operations succeed
结果
systemctl status redis-server shows active, SET/GET working