Files
SODEW/sodew-bash-main/docs/resources/redis.md
T
2026-08-18 09:40:08 +02:00

4.1 KiB

KUBE  /  k3s  /  Redis

Resource Redis

Note

A replica of three pods is created: 1 master (redis-0) + 2 slaves (redis-1, redis-2). A cluster of three RedisSentinel is created to manage the replica. When configuring the connection, the host is specified: redis-0.redis.

Warning

In the current configuration, when changing the RedisSentinel master node of the replica, there is no automatic change of connection to the new master node. Solution: adding HAProxy to automatically redirect requests to the current Redis master node.


Install

Processing

  1. Preparation.

    • Recreate the secret with the passwords root-password.
  2. Creation.

    • Prepare the import file.
    • Import the YAML.

Command:

sudo kube.sh --redis install

Example of log:

🔹[Redis] Install
✅[Redis] Delete old Secret: OK
✅[Redis] Create new Secret: OK
🔹[Redis] Preparing /app/kube/assets/yaml/redis.yaml
🔹[K3S] Applying YAML /app/kube/data/yaml/redis.yaml
💡[K3S] Waiting for pods to be ready... | 2 not ready
💡[K3S] Waiting for pods to be ready... | 1 not ready
✅[Redis] Applied /app/kube/data/yaml/redis.yaml

Remove

Command:

sudo kube.sh --redis remove

Status

Command:

sudo kube.sh --redis status

Example of log:

🔹[Redis] Status
✅[Redis] redis-0 | Role: Master | Slaves: 2
✅[Redis] redis-1 | Role: Slave | Master: redis-0.redis
✅[Redis] redis-2 | Role: Slave | Master: redis-0.redis
✅[RedisSentinel] redis-sentinel-0 | Master: mymaster [redis-0.redis:6379] | Slaves: 2 | Other sentinels: 2 | Quorum: 2
✅[RedisSentinel] redis-sentinel-0 |  Slave: 10.42.0.16:6379 [10.42.0.16:6379] | Master: redis-0.redis
✅[RedisSentinel] redis-sentinel-0 |  Slave: 10.42.0.14:6379 [10.42.0.14:6379] | Master: redis-0.redis
✅[RedisSentinel] redis-sentinel-1 | Master: mymaster [redis-0.redis:6379] | Slaves: 2 | Other sentinels: 2 | Quorum: 2
✅[RedisSentinel] redis-sentinel-1 |  Slave: 10.42.0.16:6379 [10.42.0.16:6379] | Master: redis-0.redis
✅[RedisSentinel] redis-sentinel-1 |  Slave: 10.42.0.14:6379 [10.42.0.14:6379] | Master: redis-0.redis
✅[RedisSentinel] redis-sentinel-2 | Master: mymaster [redis-0.redis:6379] | Slaves: 2 | Other sentinels: 2 | Quorum: 2
✅[RedisSentinel] redis-sentinel-2 |  Slave: 10.42.0.16:6379 [10.42.0.16:6379] | Master: redis-0.redis
✅[RedisSentinel] redis-sentinel-2 |  Slave: 10.42.0.14:6379 [10.42.0.14:6379] | Master: redis-0.redis

Info

Command:

sudo kube.sh --redis info

Example of log:

🔹[Redis] Info
🔹[Redis] redis-0
# Replication
role:master
connected_slaves:2
slave0:ip=10.42.0.14,port=6379,state=online,offset=1092850,lag=0
slave1:ip=10.42.0.16,port=6379,state=online,offset=1092714,lag=1
...
🔹[Redis] redis-1
# Replication
role:slave
master_host:redis-0.redis
master_port:6379
master_link_status:up
...
🔹[Redis] redis-2
# Replication
role:slave
master_host:redis-0.redis
master_port:6379
master_link_status:up
...
🔹[RedisSentinel] redis-sentinel-0
# Sentinel
sentinel_masters:1
...
master0:name=mymaster,status=ok,address=redis-0.redis:6379,slaves=2,sentinels=3
🔹[RedisSentinel] redis-sentinel-1
# Sentinel
sentinel_masters:1
...
master0:name=mymaster,status=ok,address=redis-0.redis:6379,slaves=2,sentinels=3
🔹[RedisSentinel] redis-sentinel-2
# Sentinel
sentinel_masters:1
...
master0:name=mymaster,status=ok,address=redis-0.redis:6379,slaves=2,sentinels=3

Version

Command:

sudo kube.sh --redis version

Example of log:

🔹[Redis] Version
✅[Redis] redis-0 | 7.4.2
✅[Redis] redis-1 | 7.4.2
✅[Redis] redis-2 | 7.4.2
✅[RedisSentinel] redis-sentinel-0 | 7.4.2
✅[RedisSentinel] redis-sentinel-1 | 7.4.2
✅[RedisSentinel] redis-sentinel-2 | 7.4.2

User list

Command:

sudo kube.sh --redis user

Example of log:

🔹[Redis] User list
default
us1_example_com
us2_example_com
us3_example_com