Redis-Sentinel on Kubernetes Setup ②


Setup (create Pods)

1. Apply YAML files in order

1) Create Config

💻 Terminal

2) Create Service

💻 Terminal

3) Create StatefulSet

💻 Terminal

Three Redis Pods and three Sentinel Pods are running, so Redis-Sentinel is in place.

2. Inspect Redis-Sentinel

1) Check roles (master/replica): redis-role.sh

Script that runs Redis ROLE to check master/replica roles

📄 redis-role.sh

Run (inspect) result: edited for readability.

💻 Terminal

2) Inspect Redis monitored by Sentinel: sentinel-info.sh

Script that runs Sentinel 'INFO SENTINEL'

📄 sentinel-info.sh

Run (inspect) result: edited for readability.
The master Sentinel monitors is 'redis-0', there are 2 replicas (slaves=2), and 3 Sentinels in total (sentinels=3).

💻 Terminal

3. 🖧 Redis-Sentinel Pod diagram

┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │Sentinel-0(98) │ │Sentinel-1(100)│ │Sentinel-2(102)│ └───────┬───────┘ └───────┬───────┘ └───────┬───────┘ └───────────────────┼───────────────────┘ ▼ ┌───────────────┐ │ Redis-0(92) │ │ 🟢Master │ └──────┬────────┘ ┌──────────┴───────────┐ ▼ ▼ ┌───────────────┐ ┌───────────────┐ │ Redis-1(94) │ │ Redis-2(96) │ │ 🟡Replica-1 │ │ 🟡Replica-2 │ └───────────────┘ └───────────────┘

4. 💽 Load data

1) Load data

If you take Redis-0 down (delete) for a failover test, Kubernetes recreates redis-0 within about 2 seconds. down-after-milliseconds is 3 seconds, so the downtime of Redis-0 is not detected. So we load about 3 million keys so a restarted Redis takes more than 5 seconds to come back (data load takes about 5 seconds).

💻 Terminal

2) Verify loaded data

① Key count: 2,955,803 ➡ redis-benchmark generates keys randomly, so duplicates mean we fall a bit short of 3 million.

💻 Terminal

② AOF file size: aof.1.incr.aof 412M
③ Pod memory: Redis 617MB. Sentinel holds no data, so its size does not grow.

💻 Terminal

➡ Pods are up and data is loaded. Next: failover test.


<< K8s Redis-Sentinel Prep ① K8s Redis-Sentinel Test ③ >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.