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:
RedisReplicationto provide Replication solution.Redisto provide Standalone solution.RedisSentinelto provide sentinel enabled mode.RedisClusterto 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)!
- define your namespace.
- It is recommended to set a specific image version rather than using latest.
- 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
- The name of the previously created RedisReplication resource name.
- The default value - change it if you need a specific name.
It is good practice to set resource limits for any deployment.