/redis-operator

Redis Operator creates/configures/manages high availability redis with sentinel automatic failover atop Kubernetes.

Primary LanguageGoApache License 2.0Apache-2.0

redis-operator

Build Status Go Report Card

NOTE: This is an alpha-status project. We do regular tests on the code and functionality, but we can not assure a production-ready stability.

Redis Operator creates/configures/manages redis-failovers atop Kubernetes.

Requirements

Redis Operator is meant to be run on Kubernetes 1.8+. All dependecies have been vendored, so there's no need to any additional download.

Versions deployed

The image versions deployed by the operator can be found on the constants file for the RedisFailover service.

Images

Redis Operator

Redis Operator Image

Operator deployment on kubernetes

In order to create Redis failovers inside a Kubernetes cluster, the operator has to be deployed. It can be done with a deployment or with the provided Helm chart.

Using a Deployment

To create the operator, you can directly create it with kubectl:

kubectl create -f https://raw.githubusercontent.com/spotahome/redis-operator/master/example/operator.yaml

This will create a deployment named redisoperator.

Using the Helm chart

From the root folder of the project, execute the following:

helm install --name redisfailover charts/redisoperator

Usage

Once the operator is deployed inside a Kubernetes cluster, a new API will be accesible, so you'll be able to create, update and delete redisfailovers.

In order to deploy a new redis-failover a specification has to be created:

kubectl create -f https://raw.githubusercontent.com/spotahome/redis-operator/master/example/redisfailover.yaml

This redis-failover will be managed by the operator, resulting in the following elements created inside Kubernetes:

  • rfr-<NAME>: Redis configmap
  • rfr-<NAME>: Redis statefulset
  • rfr-<NAME>: Redis service (if redis-exporter is enabled)
  • rfs-<NAME>: Sentinel configmap
  • rfs-<NAME>: Sentinel deployment
  • rfs-<NAME>: Sentinel service

NOTE: NAME is the named provided when creating the RedisFailover.

Connection

In order to connect to the redis-failover and use it, a Sentinel-ready library has to be used. This will connect through the Sentinel service to the Redis node working as a master. The connection parameters are the following:

url: rfs-<NAME>
port: 26379
master-name: mymaster

Cleanup

If you want to delete the operator from your Kubernetes cluster, the operator deployment should be deleted.

Also, the CRD has to be deleted too:

kubectl delete crd redisfailovers.storage.spotahome.com

Documentation

For the code documentation, you can lookup on the GoDoc.

Also, you can check more deeply information on the docs folder.