Helm 安装 Redis 集群
具有默认 sc 存储,如果没有则设置 persistenceEnabled: false
参考: https://operatorhub.io/operator/redis-operator
参考: https://ot-redis-operator.netlify.app/docs/overview/
helm repo add ot-helm https://ot-container-kit.github.io/helm-charts/
helm install redis-operator ot-helm/redis-operator --namespace ot-operators --create-namespace --version 0.19.2
kubectl describe --namespace ot-operators pods
kubectl get pods -n ot-operators
创建 redis-cluster 默认认证用户
kubectl create secret generic redis-secret \
--from-literal=redis-password="T3BzdHJlZUAxMjM0Cg=" --namespace ot-operators
安装 redis-cluster 测试集群
helm install redis-cluster ot-helm/redis-cluster \
--set redisCluster.clusterSize=3 \
--set redisCluster.redisSecret.secretName=redis-secret \
--set redisCluster.redisSecret.secretKey=redis-password \
--set redisExporter.enabled=true \
--namespace ot-operators --version 0.16.5
临时在 kube-public 命名空间下启动客户端测试
kubectl run -it --rm --image=redis --restart=Never redis-client -n kube-public -- /bin/bash
集群内部访问
redis-cluster-leader-svc-0.ot-operators.svc.cluster.local:6379
redis-cluster-leader-svc-1.ot-operators.svc.cluster.local:6379
redis-cluster-leader-svc-2.ot-operators.svc.cluster.local:6379
同 VPC 下访问
要从同一 VPC 内访问 Redis 集群,请使用 nodeRedisSvc.yaml 文件中定义的 NodePort 服务。每个服务对应一个Redis领导节点,可以通过其各自的NodePort访问
redis-cluster-leader-svc-0: Connect using
svc-ip:30025
redis-cluster-leader-svc-1: Connect using
svc-ip:30026
redis-cluster-leader-svc-2: Connect using
svc-ip:30027
Ensure the svc-ip
corresponds to the IP address of the node hosting the Kubernetes services.
root@test-jys:/tmp/test-redis# cat nodeRedisSvc.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: redis-cluster-leader-svc-0
name: redis-cluster-leader-svc-0
namespace: ot-operators
spec:
ports:
- name: redis-client
port: 6379
protocol: TCP
targetPort: 6379
nodePort: 30025
selector:
statefulset.kubernetes.io/pod-name: redis-cluster-leader-0
type: NodePort
---
apiVersion: v1
kind: Service
metadata:
labels:
app: redis-cluster-leader-svc-1
name: redis-cluster-leader-svc-1
namespace: ot-operators
spec:
ports:
- name: redis-client
port: 6379
protocol: TCP
targetPort: 6379
nodePort: 30026
selector:
statefulset.kubernetes.io/pod-name: redis-cluster-leader-1
type: NodePort
---
apiVersion: v1
kind: Service
metadata:
labels:
app: redis-cluster-leader-svc-2
name: redis-cluster-leader-svc-2
namespace: ot-operators
spec:
ports:
- name: redis-client
port: 6379
protocol: TCP
targetPort: 6379
nodePort: 30027
selector:
statefulset.kubernetes.io/pod-name: redis-cluster-leader-2
type: NodePort
Last updated