k8s_redis_standalone_1
Redis-Standalone Hands-on Guide on Kubernetes ①
YAML spec overview
Redis-Standalone overview
Redis-Standalone runs a single Redis master in one Pod.
1. Redis-Standalone YAML spec
When deploying Redis-Standalone on Kubernetes, split Config, Service, and StatefulSet into three YAML files.
2. File contents in apply order
🟢 [Step 1] Redis config: redis-config.yaml
- kind: ConfigMap
- metadata.name: redis-config
⚠️ Names may use only lowercase a-z, digits 0-9, and hyphen (`-`) (no uppercase) - This ConfigMap holds the directives used to create redis.conf.
- The default redis.conf from the Redis tarball is not used.
🧑💻 Key fields
- bind * -::* # Pod IPs are assigned dynamically and change, so bind all addresses.
KISA Cloud Vulnerability Assessment Guide requires setting a specific IP on bind for security. That is correct on VMs and bare metal, but you cannot pin bind to a fixed IP on Kubernetes.
(Explain this clearly to auditors on public-sector and financial projects.) - protected-mode no # Because bind is '*', setting protected-mode yes would block external clients.
It looks like a security exception, but Kubernetes already isolates the network, so this setting is fine. - daemonize no # Do not set this to yes.
- requirepass password # 💥 Always set a password.
If the host is on the internet, set a password even in development.
Redis is not hacked by a person at a keyboard; 💻 programs scan 24 hours a day.
Without a password, even a few minutes of a “dev” instance can be taken over.
See: 🔗 Redis Hacking
If you configure users.acl, requirepass is optional. - masterauth password # Always set this.
- users.acl: lines 65–66. Set the 64-character password ('#0cbc...') separately.
See: 🔗 ACL
💾 View redis-config.yaml
These values are the redis.conf settings redisGate has applied at 90%+ of 100+ production sites.
(Tune maxmemory to your data size)
💻 On bare metal or VMs, change the following.
- bind 114.x.y.z 127.0.0.1 -::1 -> bind a specific IP
- protected-mode yes
- port -> default 💥6379 is a prime hacking target. Use another port.
- daemonize yes
- dir /app/redis -> put pidfile, logfile, etc. in this dir
- aclfile /app/redis/users.acl -> per-user ACLs: recommended
- #maxmemory <bytes> -> leave commented (default)
① Dedicated Redis server: set 50%–90% of system RAM
② Plenty of RAM: if the host has 16GB and Redis uses 1–2GB, you can skip maxmemory
③ 💥 If Redis consumes all RAM, Linux will kill the Redis process.
🟢 [Step 2] Service: redis-service.yaml
- kind: Service
- metadata.name: redis-service
⚠️ Names may use only lowercase a-z, digits 0-9, and hyphen (`-`) (no uppercase)
- This is the Service YAML.
Even when Pod IPs change, a stable FQDN (Fully Qualified Domain Name)
lets clients reach each Redis like a network directory.
🧑💻 Key fields
- clusterIP: None # 📍 set to None (per-Pod DNS identity)
- port: 18504 # Redis port
💾 View redis-service.yaml
🟢 [Step 3] Redis Pod spec: redis-statefulset.yaml
StatefulSet spec for Redis Pods (replicas, initContainers, memory, PVC).
- kind: StatefulSet
- metadata.name: redis
⚠️ Names may use only lowercase a-z, digits 0-9, and hyphen (`-`) (no uppercase)
Kubernetes names Pods redis-0,1,2 from this name.
Pod name + serviceName form the FQDN:
redis-0.redis-service.default.svc.cluster.local
Each Redis gets a unique FQDN for Redis-to-Redis and Redis-to-app traffic.
When the IP changes, DNS maps the same FQDN to the new IP.
🧑💻 Key fields
- configMap: name: redis-config (links to Step 1 Redis config)
- serviceName: redis-service (links to Step 2 Service)
- replicas: 1 # one Redis Pod
- image: redis:8.8.2 # Redis 8.8.2, released 2026-08-17 (Mon)
- imagePullPolicy: IfNotPresent # use local image
- command script: copy ConfigMap files and inject dynamic settings
- volumeMounts mountPath /data: all Redis files
(redis.conf, users.acl, AOF, etc.).
💾 View redis-statefulset.yaml
🧑💻 initContainers command script
- ① Copy read-only redis.conf from ConfigMap to writable /data
Redis may rewrite the conf via CONFIG REWRITE and also writes it on important events. So redis.conf must live on a read-write directory.
- ② Copy users.acl
🧑💻 containers command script
- ③ Add convenient aliases to .bashrc
With '--color=auto', filenames are colored as follows:
dir file: redis-sentinel-model
exec file: cluster_create.sh
tar file: file redis-8.8.2.tar
- ④ The Redis image defaults to UTC. Switch to host OS time (Korea).
➡ YAML is ready. Next we create the Pods.
| << K8s Sidecar Pattern Test ③ | K8s Redis-Standalone ② >> |
|---|
