在 Kubernetes 上使用 Bitnami Redis Sentinel 和 Sidekiq 可以提高可伸缩性和稳定性。
创建名为 redis-sentinel-deploy.yml 的文件,并输入以下内容:
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-sentinel
spec:
replicas: 3
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
role: sentinel
spec:
containers:
- name: redis
image: bitnami/redis-sentinel:latest
args: [
"redis-server",
"/opt/bitnami/redis/mounted-etc/redis.conf",
"--sentinel"
]
volumeMounts:
- name: redis-conf
mountPath: /opt/bitnami/redis/mounted-etc/redis.conf
subPath: redis-sentinel.conf
volumes:
- name: redis-conf
configMap:
name: redis-sentinel-config
items:
- key: redis-sentinel.conf
path: redis-sentinel.conf
创建名为 redis-sentinel-svc.yml 的文件,并输入以下内容:
apiVersion: v1
kind: Service
metadata:
name: redis-sentinel
spec:
ports:
- name: redis
targetPort: 26379
port: 26379
selector:
app: redis
role: sentinel
创建名为 redis-sentinel-cm.yml 的文件,并输入以下内容:
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-sentinel-config
data:
redis-sentinel.conf: |-
port 26379
daemonize no
pidfile "/opt/bitnami/redis/var/run/redis-sentinel.pid"
logfile "/opt/bitnami/redis/var/log/redis/redis-sentinel.log"
sentinel monitor mymaster