Redis Operator creates/configures/manages high availability redis with sentinel automatic failover atop Kubernetes.
Clone or download
jchanam Merge pull request #103 from Paic/examples-fix
Use our created ServiceAccount
Latest commit 4a7661c Oct 30, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add issue and PR templates Apr 16, 2018
api/redisfailover Merge pull request #88 from rhefner1/exporter-probe-flag Oct 16, 2018
charts/redisoperator [DEVOPS-807] Add servicemonitor for prometheus Sep 13, 2018
client/k8s/clientset/versioned [DEVOPS-745] Update codegen Jul 2, 2018
cmd [DEVOPS-745] Adapt code to Kooper new version Jul 2, 2018
docker [DEVOPS-745] Change tools to use v1.10.5 Jul 2, 2018
docs [DEVOPS-695] Improve documentation Feb 20, 2018
example Missing ressources separtors Oct 30, 2018
hack [DEVOPS-694] Add scripts to autogenerate code Feb 19, 2018
log [DEVOPS-694] Move log to root Feb 19, 2018
metrics [DEVOPS-824] Delete metric if redis-failover no longer exist Sep 14, 2018
mocks [DEVOPS-855] Use oldest pod to convert to master Oct 8, 2018
operator/redisfailover Merge pull request #88 from rhefner1/exporter-probe-flag Oct 16, 2018
scripts [DEVOPS-745] Use last minikube version for integration tests and v1.1… Jul 2, 2018
service [DEVOPS-810] Apply redis and sentinel configuration continuously Aug 23, 2018
test/integration/redisfailover [DEVOPS-745] Fix integration test Jul 2, 2018
vendor [DEVOPS-745] Update json-iterator Jul 2, 2018
.gitattributes Opensourced project Nov 7, 2017
.gitignore Opensourced project Nov 7, 2017
.travis.yml [DEVOPS-745] Change minikube version to 0.25.2 Jul 3, 2018
Gopkg.lock [DEVOPS-745] Update json-iterator Jul 2, 2018
Gopkg.toml [DEVOPS-745] Update dependencies to use Kubernetes v1.10.5 Jul 2, 2018
LICENSE Fix LICENSE Feb 15, 2018
Makefile [DEVOPS-855] Bump version to 0.5.4 Oct 8, 2018
README.md Fix README links Oct 15, 2018

README.md

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 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/all-redis-operator-resources.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/all-options.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. IMPORTANT: the name of the redis-failover to be created cannot be longer that 48 characters, due to prepend of redis/sentinel identification and statefulset limitation.

Persistance

The operator has the ability of add persistance to Redis data. By default an emptyDir will be used, so the data is not saved.

In order to have persistance, a PersistentVolumeClaim usage is allowed. The full PVC definition has to be added to the Redis Failover Spec under the Storage section.

IMPORTANT: By default, the persistent volume claims will be deleted when the Redis Failover is. If this is not the expected usage, a keepAfterDeletion flag can be added under the storage section of Redis. An example is given.

Custom configurations

It is possible to configure both Redis and Sentinel. This is done with the customConfig option inside their spec. It is a list of configurations and their values.

Example:

sentinel:
  customConfig:
    - "down-after-milliseconds 2000"
    - "failover-timeout 3000"
redis:
  customConfig:
    - "maxclients 100"
    - "hz 50"

*Important: this options will be set via config set or sentinel set mymaster. In the Sentinel options, there are some "conversions" to be made.

  • Configuration on the sentinel.conf: sentinel down-after-milliseconds mymaster 2000
  • Configuration on the configOptions: down-after-milliseconds 2000

Important 2: do NOT change the options used for control the redis/sentinel such as port, bind, dir, etc.

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.