# Redis Cluster

The redis setup cluster mode can be customized using custom configuration. If redis setup is done by Helm, in that case values.yaml can be updated.

But if the setup is not done via Helm, in that scenario we may have to customize the CRD parameters.

In this configuration section, we have these configuration parameters:-

# Helm Parameters

Name Default Value Description
imagePullSecrets [] List of image pull secrets, in case redis image is getting pull from private registry
redisCluster.clusterSize 3 Size of the redis cluster leader and follower nodes
redisCluster.clusterVersion v7 Major version of Redis setup, values can be v6 or v7
redisCluster.persistenceEnabled true Persistence should be enabled or not in the Redis cluster setup
redisCluster.secretName redis-secret Name of the existing secret in Kubernetes
redisCluster.secretKey password Name of the existing secret key in Kubernetes
redisCluster.image quay.io/opstree/redis Name of the redis image
redisCluster.tag v6.2 Tag of the redis image
redisCluster.imagePullPolicy IfNotPresent Image Pull Policy of the redis image
redisCluster.leader.affinity {} Affinity for node and pods for redis leader statefulset
redisCluster.follower.affinity {} Affinity for node and pods for redis follower statefulset
externalService.enabled false If redis service needs to be exposed using LoadBalancer or NodePort
externalService.annotations {} Kubernetes service related annotations
externalService.serviceType NodePort Kubernetes service type for exposing service, values - ClusterIP, NodePort, and LoadBalancer
externalService.port 6379 Port number on which redis external service should be exposed
serviceMonitor.enabled false Servicemonitor to monitor redis with Prometheus
serviceMonitor.interval 30s Interval at which metrics should be scraped.
serviceMonitor.scrapeTimeout 10s Timeout after which the scrape is ended
serviceMonitor.namespace monitoring Namespace in which Prometheus operator is running
redisExporter.enabled true Redis exporter should be deployed or not
redisExporter.image quay.io/opstree/redis-exporter Name of the redis exporter image
redisExporter.tag v6.2 Tag of the redis exporter image
redisExporter.imagePullPolicy IfNotPresent Image Pull Policy of the redis exporter image
redisExporter.env [] Extra environment variables which needs to be added in redis exporter
nodeSelector {} NodeSelector for redis statefulset
priorityClassName "" Priority class name for the redis statefulset
storageSpec {} Storage configuration for redis setup
securityContext {} Security Context for redis pods for changing system or kernel level parameters
tolerations [] Tolerations for redis statefulset
sidecars [] Sidecar for redis pods

# CRD Parameters

These are the CRD Parameters which is currently supported by Redis Exporter for standalone CRD.

clusterSize

clusterSize is size of the Redis leader and follower nodes.

spec:
  clusterSize: 3

clusterVersion

clusterVersion is a paramter through which we can control Redis major values. The possible values are:-

  • v6
  • v7
spec:
  clusterVersion: v7

persistenceEnabled

persistenceEnabled is a configuration parameter to enable the persistence storage in redis cluster. The possible values are:-

  • true
  • false
spec:
  persistenceEnabled: true

redisLeader

redisLeader is the field for Redis leader related configurations.

spec:
  redisLeader:
    redisConfig:
      additionalRedisConfig: redis-external-config
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
          - matchExpressions:
            - key: disktype
              operator: In
              values:
              - ssd

redisFollower

redisFollower is the field for Redis follower related configurations.

spec:
  redisFollower:
    redisConfig:
      additionalRedisConfig: redis-external-config
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
          - matchExpressions:
            - key: disktype
              operator: In
              values:
              - ssd

kubernetesConfig

In the kubernetesConfig section, we define configuration related to Kubernetes.

spec:
  kubernetesConfig:
    image: quay.io/opstree/redis:v6.2
    imagePullPolicy: IfNotPresent
    resources:
      requests:
        cpu: 101m
        memory: 128Mi
      limits:
        cpu: 101m
        memory: 128Mi
    redisSecret:
      name: redis-secret
      key: password
    imagePullSecrets:
      - name: regcred

redisExporter

redisExporter configuration which enable the metrics for Redis Database to get monitored by Prometheus.

spec:
  redisExporter:
    enabled: true
    image: quay.io/opstree/redis-exporter:1.0
    imagePullPolicy: Always
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 100m
        memory: 128Mi
    env:
    - name: REDIS_EXPORTER_INCL_SYSTEM_METRICS
      value: "true"
    - name: UI_PROPERTIES_FILE_NAME
      valueFrom:
        configMapKeyRef:
          name: game-demo
          key: ui_properties_file_name
    - name: SECRET_USERNAME
      valueFrom:
        secretKeyRef:
          name: mysecret
          key: username

storage

storage configuration for Redis Statefulset pods.

spec:
  storage:
    volumeClaimTemplate:
      spec:
        storageClassName: standard
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 1Gi

priorityClassName

Name of the Kubernetes priority class which you want to associate with redis setup.

spec:
  priorityClassName: priority-100

nodeSelector

Map of the labels which you want to use as nodeSelector.

spec:
  nodeSelector:
    kubernetes.io/hostname: minikube

securityContext

Kubernetes security context for redis pods.

spec:
  securityContext:
    runAsUser: 1000
    fsGroup: 1000

tolerations

Tolerations for nodes and pods in Kubernetes.

spec:
  tolerations:
  - key: "key1"
    operator: "Equal"
    value: "value1"
    effect: "NoSchedule"

sidecars

Sidecars for redis pods

spec:
  sidecars:
  - name: "sidecar1"
    image: "image:1.0"
    imagePullPolicy: Always
    resources:
      limits:
        cpu: 50m
        memory: 64Mi
      requests:
        cpu: 10m
        memory: 32M
    env:
    - name: VAR_NAME
      value: "value1"

pdb

PodDisruptionBugets for redis cluster pods

spec:
  pdb:
    enabled: true
    maxUnavailable: 1
    minAvailable: 1

probes

Probes for redis leader and follower pods

#  redisFollower:
#  redisLeader:
spec:
    readinessProbe:
      failureThreshold: 5
      initialDelaySeconds: 15
      periodSeconds: 15
      successThreshold: 1
      timeoutSeconds: 5
    livenessProbe:
      failureThreshold: 5
      initialDelaySeconds: 15
      periodSeconds: 15
      successThreshold: 1
      timeoutSeconds: 5

TLS

TLS configuration for redis cluster

spec:
  TLS:
    ca: ca.key
    cert: tls.crt
    key: tls.key
    secret:
      secretName: sample-cert