# redis-cluster-operator
## Overview
Redis Cluster Operator manages [Redis Cluster](https://redis.io/topics/cluster-spec) atop Kubernetes.
The operator itself is built with the [Operator framework](https://github.com/operator-framework/operator-sdk).
![Redis Cluster atop Kubernetes](/static/redis-cluster.png)
Each master node and its slave nodes is managed by a statefulSet, create a headless svc for each statefulSet,
and create a clusterIP service for all nodes.
Each statefulset uses PodAntiAffinity to ensure that the master and slaves are dispersed on different nodes.
At the same time, when the operator selects the master in each statefulset, it preferentially select the pod
with different k8s nodes as master.
Table of Contents
=================
* [redis-cluster-operator](#redis-cluster-operator)
* [Overview](#overview)
* [Table of Contents](#table-of-contents)
* [Prerequisites](#prerequisites)
* [Features](#features)
* [Quick Start](#quick-start)
* [Deploy redis cluster operator](#deploy-redis-cluster-operator)
* [Install Step by step](#install-step-by-step)
* [Install using helm chart](#install-using-helm-chart)
* [Usage](#usage)
* [Deploy a sample Redis Cluster](#deploy-a-sample-redis-cluster)
* [Scaling Up the Redis Cluster](#scaling-up-the-redis-cluster)
* [Scaling Down the Redis Cluster](#scaling-down-the-redis-cluster)
* [Backup and Restore](#backup-and-restore)
* [Prometheus Discovery](#prometheus-discovery)
* [Create Redis Cluster with password](#create-redis-cluster-with-password)
* [Persistent Volume](#persistent-volume)
* [Custom Configuration](#custom-configuration)
* [Custom Service](#custom-service)
* [Custom Resource](#custom-resource)
* [ValidatingWebhook](#validatingwebhook)
* [End to end tests](#end-to-end-tests)
## Prerequisites
* go version v1.13+.
* Access to a Kubernetes v1.13.10 cluster.
## Features
- __Customize the number of master nodes and the number of replica nodes per master__
- __Password__
- __Safely Scaling the Redis Cluster__
- __Backup and Restore__
- __Persistent Volume__
- __Custom Configuration__
- __Prometheus Discovery__
## Quick Start
### Deploy redis cluster operator
#### Install Step by step
Register the DistributedRedisCluster and RedisClusterBackup custom resource definition (CRD).
```
$ kubectl create -f deploy/crds/redis.kun_distributedredisclusters_crd.yaml
$ kubectl create -f deploy/crds/redis.kun_redisclusterbackups_crd.yaml
```
A namespace-scoped operator watches and manages resources in a single namespace, whereas a cluster-scoped operator watches and manages resources cluster-wide.
You can chose run your operator as namespace-scoped or cluster-scoped.
```
// cluster-scoped
$ kubectl create -f deploy/service_account.yaml
$ kubectl create -f deploy/cluster/cluster_role.yaml
$ kubectl create -f deploy/cluster/cluster_role_binding.yaml
$ kubectl create -f deploy/cluster/operator.yaml
// namespace-scoped
$ kubectl create -f deploy/service_account.yaml
$ kubectl create -f deploy/namespace/role.yaml
$ kubectl create -f deploy/namespace/role_binding.yaml
$ kubectl create -f deploy/namespace/operator.yaml
```
#### Install using helm chart
Add Helm repository
```
helm repo add ucloud-operator https://ucloud.github.io/redis-cluster-operator/
helm repo update
```
Install chart
```
helm install --generate-name ucloud-operator/redis-cluster-operator
```
Verify that the redis-cluster-operator is up and running:
```
$ kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
redis-cluster-operator 1/1 1 1 1d
```
### Usage
#### Deploy a sample Redis Cluster
NOTE: **Only the redis cluster that use persistent storage(pvc) can recover after accidental deletion or rolling update.Even if you do not use persistence(like rdb or aof), you need to set pvc for redis.**
```
$ kubectl apply -f deploy/example/redis.kun_v1alpha1_distributedrediscluster_cr.yaml
```
Verify that the cluster instances and its components are running.
```
$ kubectl get distributedrediscluster
NAME MASTERSIZE STATUS AGE
example-distributedrediscluster 3 Scaling 11s
$ kubectl get all -l redis.kun/name=example-distributedrediscluster
NAME READY STATUS RESTARTS AGE
pod/drc-example-distributedrediscluster-0-0 1/1 Running 0 2m48s
pod/drc-example-distributedrediscluster-0-1 1/1 Running 0 2m8s
pod/drc-example-distributedrediscluster-1-0 1/1 Running 0 2m48s
pod/drc-example-distributedrediscluster-1-1 1/1 Running 0 2m13s
pod/drc-example-distributedrediscluster-2-0 1/1 Running 0 2m48s
pod/drc-example-distributedrediscluster-2-1 1/1 Running 0 2m15s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/example-distributedrediscluster ClusterIP 172.17.132.71 <none> 6379/TCP,16379/TCP 2m48s
service/example-distributedrediscluster-0 ClusterIP None <none> 6379/TCP,16379/TCP 2m48s
service/example-distributedrediscluster-1 ClusterIP None <none> 6379/TCP,16379/TCP 2m48s
service/example-distributedrediscluster-2 ClusterIP None <none> 6379/TCP,16379/TCP 2m48s
NAME READY AGE
statefulset.apps/drc-example-distributedrediscluster-0 2/2 2m48s
statefulset.apps/drc-example-distributedrediscluster-1 2/2 2m48s
statefulset.apps/drc-example-distributedrediscluster-2 2/2 2m48s
$ kubectl get distributedrediscluster
NAME MASTERSIZE STATUS AGE
example-distributedrediscluster 3 Healthy 4m
```
#### Scaling Up the Redis Cluster
Increase the masterSize to trigger the scaling up.
```
apiVersion: redis.kun/v1alpha1
kind: DistributedRedisCluster
metadata:
annotations:
# if your operator run as cluster-scoped, add this annotations
redis.kun/scope: cluster-scoped
name: example-distributedrediscluster
spec:
# Increase the masterSize to trigger the scaling.
masterSize: 4
ClusterReplicas: 1
image: redis:5.0.4-alpine
```
#### Scaling Down the Redis Cluster
Decrease the masterSize to trigger the scaling down.
```
apiVersion: redis.kun/v1alpha1
kind: DistributedRedisCluster
metadata:
annotations:
# if your operator run as cluster-scoped, add this annotations
redis.kun/scope: cluster-scoped
name: example-distributedrediscluster
spec:
# Increase the masterSize to trigger the scaling.
masterSize: 3
ClusterReplicas: 1
image: redis:5.0.4-alpine
```
#### Backup and Restore
NOTE: **Only Ceph S3 object storage and PVC is supported now**
Backup
```
$ kubectl create -f deploy/example/backup-restore/redisclusterbackup_cr.yaml
```
Restore from backup
```
$ kubectl create -f deploy/example/backup-restore/restore.yaml
```
#### Prometheus Discovery
```
$ kubectl create -f deploy/example/prometheus-exporter.yaml
```
#### Create Redis Cluster with password
```
$ kubectl create -f deploy/example/custom-password.yaml
```
#### Persistent Volume
```
$ kubectl create -f deploy/example/persistent.yaml
```
#### Custom Configuration
```
$ kubectl create -f deploy/example/custom-config.yaml
```
#### Custom Service
```
$ kubectl create -f deploy/example/custom-service.yaml
```
#### Custom Resource
```
$ kubectl create -f deploy/example/custom-resources.yaml
```
## ValidatingWebhook
see [ValidatingWebhook](/hack/webhook/README.md)
## End to end tests
see [e2e](/test/e2e/README.md)
没有合适的资源?快使用搜索试试~ 我知道了~
Redis Cluster Operator 在 Kubernetes 上创建并管理 Redis 集群 .zip
共158个文件
go:93个
yaml:32个
sh:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 161 浏览量
2024-12-02
20:40:58
上传
评论
收藏 394KB ZIP 举报
温馨提示
redis-cluster-operator概述Redis Cluster Operator在 Kubernetes 上管理Redis Cluster 。操作符本身是用操作符框架构建的。每个主节点及其从属节点由一个 statefulSet 进行管理,为每个 statefulSet 创建一个 headless svc,并为所有节点创建一个 clusterIP 服务。每个statefulset都使用PodAntiAffinity来保证master和slaves分散在不同的节点上,同时operator在每个statefulset中选择master的时候,会优先选择不同k8s节点的pod作为master。目录redis-cluster-operator概述目录先决条件特征快速入门部署 redis 集群操作员逐步安装使用 helm chart 安装用法部署示例 Redis 集群扩展 Redis 集群缩小 Redis 集群备份和恢复普罗米修斯发现使用密码创建 Redis 集群持久卷自定义配置定制服务自定义资源ValidatingWeb
资源推荐
资源详情
资源评论
收起资源包目录
Redis Cluster Operator 在 Kubernetes 上创建并管理 Redis 集群 .zip (158个子文件)
rename.conf 30B
Dockerfile 993B
Dockerfile 465B
Dockerfile 377B
Dockerfile 374B
entrypoint 393B
.gitignore 1KB
admin.go 16KB
sync_handler.go 15KB
zz_generated.deepcopy.go 15KB
statefulset.go 14KB
distributedrediscluster_controller.go 13KB
migration.go 13KB
sync_handler.go 13KB
operator_util.go 13KB
distributedrediscluster_webhook_test.go 12KB
zz_generated.openapi.go 11KB
ensurer.go 11KB
redisclusterbackup_controller.go 10KB
node.go 10KB
connections.go 9KB
framework.go 8KB
redisclusterbackup_types.go 8KB
migration_test.go 8KB
distributedrediscluster_types.go 8KB
clusterinfo.go 7KB
main.go 7KB
placement.go 7KB
osm.go 6KB
status.go 6KB
helper.go 6KB
slot.go 5KB
drcb_test.go 5KB
rebalance.go 5KB
default.go 5KB
placement_v2.go 4KB
clustersplit.go 4KB
statefulset.go 4KB
exec.go 4KB
drc_test.go 4KB
clustersplit_test.go 4KB
statefulset_test.go 4KB
ensurer_test.go 3KB
configmap.go 3KB
redis.go 3KB
distributedrediscluster_webhook.go 3KB
client.go 3KB
untrustenodes.go 3KB
helper.go 3KB
constants.go 3KB
cluster.go 3KB
poddisruptionbudget.go 3KB
errors.go 2KB
configmap_test.go 2KB
slot_test.go 2KB
rclone.go 2KB
helper.go 2KB
service.go 2KB
checker.go 2KB
failednodes.go 2KB
pod.go 2KB
configmap.go 2KB
batchjob.go 2KB
customresource.go 2KB
errors.go 2KB
service.go 2KB
parse_test.go 2KB
pvc.go 2KB
goredis_util.go 1KB
terminatingpod.go 1KB
healer.go 1KB
node_test.go 1KB
util.go 1KB
string.go 938B
scoped.go 933B
parse.go 911B
util.go 903B
drcb_suite_test.go 892B
rename_cmd.go 862B
poddisruptionbudget.go 851B
roles.go 820B
compare.go 804B
drc_suite_test.go 797B
rebalance_test.go 782B
register.go 734B
client.go 625B
controller.go 415B
labels.go 332B
apis.go 315B
add_distributedrediscluster.go 301B
add_redisclusterbackup.go 291B
addtoscheme_redis_v1alpha1.go 286B
heal.go 267B
group.go 236B
event.go 232B
version.go 189B
types.go 175B
doc.go 164B
tools.go 149B
math.go 105B
共 158 条
- 1
- 2
资源评论
赵闪闪168
- 粉丝: 1660
- 资源: 5391
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功