Skip to content

Operators

Operators are software extensions to Kubernetes that make use of custom resources to manage applications and their components. Operators follow Kubernetes principles. Operators are clients of the Kubernetes API that act as controllers for a Custom Resource.

Redis operator

In HPC Kubernetes cluster the Redis Operator is deployed via Helm. It offers these custom resources for setting up Redis:

  • RedisReplication to provide Replication solution.
  • Redis to provide Standalone solution.
  • RedisSentinel to provide sentinel enabled mode.
  • RedisCluster to have Redis deployed as a cluster.

Here is an example how to set up Redis in sentinel mode.

It is important that the replicated Redis service is deployed first and then sentinel. The Redis replicated solution must be ready and the pods must have roles defined as master/slave.

apiVersion: redis.redis.opstreelabs.in/v1beta2
kind: RedisReplication
metadata:
  name:  redis-replicated
  namespace: <your-namespace> # (1)!
spec:
  clusterSize: 3
  podSecurityContext:
    runAsUser: 1000
    fsGroup: 1000
  kubernetesConfig:
    image: quay.io/opstree/redis:latest # (2)!
    imagePullPolicy: IfNotPresent
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 500m
        memory: 256Mi
  storage:
    volumeClaimTemplate:
      spec:
        accessModes: 
          - "ReadWriteOnce"
        resources:
          requests:
            storage: 1Gi # (3)!
  1. define your namespace.
  2. It is recommended to set a specific image version rather than using latest.
  3. Set the needed volume size.

After the Redis replicated setup is in Ready state, deploy Sentinel:

apiVersion: redis.redis.opstreelabs.in/v1beta2
kind: RedisSentinel
metadata:
  name: redis-sentinel
  namespace: <your-namespace>
spec:
  clusterSize: 3
  podSecurityContext:
    runAsUser: 1000
    fsGroup: 1000
  redisSentinelConfig:
    redisReplicationName: redis-replicated # (1) !
    masterGroupName: myMaster # (2) !
  kubernetesConfig:
    image: quay.io/opstree/redis-sentinel:latest
    imagePullPolicy: IfNotPresent
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 500m
        memory: 256Mi
  1. The name of the previously created RedisReplication resource name.
  2. The default value - change it if you need a specific name.

It is good practice to set resource limits for any deployment.