Skip to main content

Command Palette

Search for a command to run...

How to install Redis Sentinel using Helm in K8S

Updated
1 min read
T

I am a dedicated software engineer with a deep passion for security and a commitment to developing robust and scalable solutions. With over three years of hands-on experience in the .NET ecosystem, I have built, maintained, and optimized various software applications, demonstrating my ability to adapt to diverse project needs. In addition to my expertise in .NET, I have six months of specialized experience working with Spring Boot and ReactJS, further broadening my skill set to include full-stack development and modern web technologies. My professional journey includes deploying small to medium-sized systems to cloud platforms and on-premises environments, where I have ensured reliability, scalability, and efficient resource utilization. This combination of skills and experience reflects my versatility and commitment to staying at the forefront of the ever-evolving tech landscape.

Adding bitnami repo into local repo helm

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo ls

Cloning repository Redis on bitnami to machine

mkdir redis-sentinel
cd ./redis-sentinel
helm fetch bitnami/redis --untar

Make changes to the configurations

Edit values.yaml file

replica.replicaCount: 2
sentinel.enabled: true
sentinel.quorum: 2
sentinel.masterSet: mymaster
global.redis.password: <YOUR_PASSWORD>

Creating a new namespace and installing redis-sentinel

kubectl create namespace redis-sentinel
helm install redis-sentinel ./ -n redis-sentinel
kubectl get pods -n redis-sentinel

How to find a current primary master host

redis-cli -h redis-sentinel -p 26379 -a 'YOUR_PASSWORD' SENTINEL get-master-addr-by-name mymaster

Example response: redis-sentinel-node-0.redis-sentinel-headless.redis-sentinel.svc.cluster.local

The format of that response is:

<pod_name>.<service_name>.<namespace>.svc.cluster.local


Config Redis Commander for accessing Redis Sentinel

apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-commander
  annotations:
    container.apparmor.security.beta.kubernetes.io/redis-commander: runtime/default
    container.security.alpha.kubernetes.io/redis-commander: runtime/default
  labels:
    app.kubernetes.io/part-of: redis-sentinel
    app.kubernetes.io/name: redis-commander
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis-commander
  template:
    metadata:
      labels:
        app: redis-commander
        app.kubernetes.io/part-of: redis-sentinel
        app.kubernetes.io/name: redis-commander
    spec:
      automountServiceAccountToken: false
      containers:
        - name: redis-commander
          image: ghcr.io/joeferner/redis-commander
          imagePullPolicy: Always
          env:
            - name: SENTINEL_GROUP
              value: "mymaster"
            - name: SENTINEL_PASSWORD
              value: "sJxpl1HBQZLpNoI"
            - name: REDIS_PASSWORD
              value: "sJxpl1HBQZLpNoI"
            - name: SENTINELS
              value: "redis-sentinel-node-0.redis-sentinel-headless.redis-sentinel.svc.cluster.local:26379,redis-sentinel-node-1.redis-sentinel-headless.redis-sentinel.svc.cluster.local:26379,redis-sentinel-node-2.redis-sentinel-headless.redis-sentinel.svc.cluster.local:26379"
          ports:
            - name: redis-commander
              containerPort: 8081
          resources:
            limits:
              cpu: "500m"
              memory: "512M"
          securityContext:
            runAsNonRoot: true
            readOnlyRootFilesystem: false
            allowPrivilegeEscalation: false
            capabilities:
              drop:
                - ALL
109 views