OT-CONTAINER-KIT / helm-charts

A repository which that will contain helm charts with best and security practices.
https://ot-container-kit.github.io/helm-charts
49 stars 84 forks source link

Redis Replication HA with default storage class from rancher #124

Closed astingengo closed 1 year ago

astingengo commented 1 year ago

Hi,

I'm using this storage class https://github.com/rancher/local-path-provisioner I'm deployed Redis Replication and Sentinel in 3 nodes Using this:

---
apiVersion: v1
kind: Secret
metadata:
  name: redis-private
  namespace: default
  annotations:
    helm.sh/resource-policy: keep
data:
  password: "secret-here"
---
apiVersion: v1
kind: Service
metadata:
  name: redis-master
  namespace: default
  labels:
    name: redis-master
spec:
  selector:
    statefulset.kubernetes.io/pod-name: redis-replication-0
  ports:
    - protocol: TCP
      port: 6379
      targetPort: 6379
  type: ClusterIP
---
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: RedisReplication
metadata:
  name: redis-replication
  namespace: default
  labels:
    app: redis
    type: backend
spec:
  clusterSize: 3
  securityContext:
    runAsUser: 1000
    fsGroup: 1000
  kubernetesConfig:
    image: quay.io/opstree/redis:v7.0.5
    imagePullPolicy: IfNotPresent
    redisSecret:
      name: redis-private
      key: password
    resources:
      requests:
        memory: 1Gi
        cpu: "0.3"
      limits:
        memory: 4Gi
        cpu: "4"
  storage:
    volumeClaimTemplate:
      spec:
        storageClassName: rancher-default-storage-class
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 10Gi
  redisExporter:
    enabled: true
    image: quay.io/opstree/redis-exporter:v1.44.0
    imagePullPolicy: IfNotPresent
---
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: RedisSentinel
metadata:
  name: sentinel
  namespace: default
  labels:
    app: sentinel
    type: backend
spec:
  clusterSize: 3
  securityContext:
    runAsUser: 1000
    fsGroup: 1000
  redisSentinelConfig:
    redisReplicationName : redis
  kubernetesConfig:
    image: quay.io/opstree/redis-sentinel:v7.0.7
    imagePullPolicy: IfNotPresent
    resources:
      requests:
        cpu: 101m
        memory: 128Mi
      limits:
        cpu: 101m
        memory: 128Mi

I'm creating redis-master because if using default svc it will be linked to slave so not able to write into Redis. [question here as well: shouldn't we have a default svc that will ALWAYS be linked to master?] Everything looks good if but lets say if redis-0 seats on node #2 and I'll manually shutdown node #2 redis-0 [master] will not came alive automatically.

Now, with manual intervention it will do but the other problem is that when it will be alive, it will not be aware of slave 1 and 2. If I'll not manually restart all redis pods master will never be aware of slaves.

Shouldn't this be done automatically by sentinels?

Am I doing something wrong?

Regards,

shubham-cmyk commented 1 year ago
  redisSentinelConfig:
    redisReplicationName : redis

Above is not properly configured it should be redis-replication as

apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: RedisReplication
metadata:
  name: redis-replication
  namespace: default

@astingengo Open The issue if this issue still persist.