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

164 lines
4.1 KiB
Markdown

[KUBE](../../README.md)  /  [k3s](../k3s.md)  /  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](#install)
- [Remove](#remove)
- [Status](#status)
- [Info](#info)
- [Version](#version)
- [User list](#user-list)
***
## Install
### Processing
1. Preparation.
- Recreate the secret with the passwords `root-password`.
2. Creation.
- Prepare the import file.
- Import the YAML.
Command:
```bash
sudo kube.sh --redis install
```
Example of log:
```bash
🔹[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:
```bash
sudo kube.sh --redis remove
```
***
## Status
Command:
```bash
sudo kube.sh --redis status
```
Example of log:
```bash
🔹[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:
```bash
sudo kube.sh --redis info
```
Example of log:
```bash
🔹[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:
```bash
sudo kube.sh --redis version
```
Example of log:
```bash
🔹[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:
```bash
sudo kube.sh --redis user
```
Example of log:
```bash
🔹[Redis] User list
default
us1_example_com
us2_example_com
us3_example_com
```