redis有单机,复制,分片这几种方式
复制就是把一个redis的数据,复制到另外一个redis,
分片就是把key分分组,一个redis拥有一部分key,另外一个redis拥有另外一部分key
分片+复制
有6个节点,3个master,3个slaver
1. 参考
https://operatorhub.io/operator/redis-operator
https://github.com/ot-container-kit/redis-operator
https://redis.io/topics/cluster-tutorial
2. k3s安装
stateful pod, headless service
因为cluster不依赖dns,只依赖pod ip,要特别注意pod重启导致ip变化,但是stateful pod ip是不会变的
3. Operator Lifecycle Manager安装
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.17.0/install.sh
| bash -s v0.17.0
4. operator 安装
kubectl create -f https://operatorhub.io/install/redis-operator.yaml
5. 安装redis集群
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: Redis
metadata:
name: redis
spec:
mode: cluster
size: 3
global:
image: 'quay.io/opstree/redis:v6.2'
imagePullPolicy: IfNotPresent
password: Opstree@1234
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 100m
memory: 128Mi
master:
service:
type: ClusterIP
redisConfig: {}
slave:
service:
type: ClusterIP
redisConfig: {}
service:
type: ClusterIP
redisConfig: {}
redisExporter:
enabled: true
image: 'quay.io/opstree/redis-exporter:1.0'
imagePullPolicy: Always
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 100m
memory: 128Mi
storage:
volumeClaimTemplate:
spec:
storageClassName: local-path
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
6. 安装之后有6个pod,3个master,3个slaver