redis-operator

module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2019 License: Apache-2.0

README

CircleCI GitHub license

Redis Operator - An easy way of deploying Redis on Kubernetes

This is Redis Operator which will create/manage Redis on the top of the Kubernetes. The project is inspired by the Operator Framework which is initiated by the CoreOS.

Requirements

  • Golang                ---> If you want to do development
  • Kubernetes 1.9+ ---> This operator supports Kubernetes 1.9+ versions

Overview

Redis Operator deploy and manage the Redis instances in form of cluster or Master and Slave depending upon on your configuration

Things you should know about Redis Operator:-

  • 3 is a minimum number of Redis instances.
  • Redis 5.0 is the minimum supported version.
  • Redis Operator is not a distributed system. It leverages a simple leader election protocol. You can run multiple instances of Redis Operator.

The folder structure of operator is something like this:-

redis-operator      ---> Main codebase directory for Redis Operator
├── build           ---> All the artifacts(binary) and Dockerfile
├── cmd             ---> Contains main.go which is the entry point to initialize and start this operator
├── deploy          ---> Contains manifests for deploying operator on kubernetes cluster
├── example         ---> Example file for deploying redis cluster
├── go.mod          ---> Go module file for dependency management
├── Gopkg.lock      ---> Lock file generated by dep for dependency management
├── Gopkg.toml      ---> Main dep file for managing go dependencies with dep
├── LICENSE         ---> Apache-2.0 License for this operator
├── pkg             ---> Contains main api and controller files for operator operations
├── vendor          ---> The golang vendor directory contains the local copies of external dependencies
└── version         ---> This directory have the version information of this operator

Getting Started

Deploying Redis Operator
  • Create a namespace for redis-operator
kubectl create namespace redis-operator
  • Deploy the CRDs and Operator in redis-operator namespace
kubectl apply -Rf deploy
  • Check if operator is running fine or not
kubectl -n redis-operator get deployment
kubectl get pods -n redis-operator
Deploying Redis
  • Redis can be deployed by creating a Redis Custom Resource(CR).
  • Create a Redis CR that deploys a 3 node Redis replication in high availablilty mode:
kubectl create -f example/deployment.yaml
  • Wait until the redis pods are up. It will show the name for the Pod of the current master instance and the total number of replicas in the setup:
kubectl get redis example -n redis-operator
  • Scale the deployment:
kubectl scale redis example --replicas 4 -n redis-operator
redis.opstree.com/example scaled
kubectl get redis example -n redis-operator
NAME      MASTER            REPLICAS   DESIRED   AGE
example   redis-example-0   4          4         24d

What Redis Operator provides you?

Redis Operator creates the following resources owned by the corresponding Redis.

  • Kubernetes API                     ---> redis.opstree.com
  • Secret                                    ---> In case password setup is enable
  • ConfigMap                             ---> For Redis Configuration Management
  • PodDisruptionBudget          ---> For managing the Disruptions
  • StatefulSet                            ---> StatefulSets for redis cluster deployment
  • Services                                 ---> For communication with redis in kubernetes cluster
    • redis-example                ---> covers all pods
    • redis-example-master   ---> service for access to the master pod

To Do

  • Implement CI pipeline for this code.
  • Add the Design and Goal information in the README.
  • Create test cases for the operator

Directories

Path Synopsis
cmd
pkg
apis/k8s/v1alpha1
Package v1alpha1 contains API Schema definitions for the redis v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=redis.opstree.com
Package v1alpha1 contains API Schema definitions for the redis v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=redis.opstree.com

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL