|
2 | 2 |
|
3 | 3 | ## Overview |
4 | 4 |
|
5 | | -Redis Cluster Operator setup a [Redis Cluster](https://redis.io/topics/cluster-spec) atop Kubernetes. |
| 5 | +Redis Cluster Operator manages [Redis Cluster](https://redis.io/topics/cluster-spec) atop Kubernetes. |
| 6 | + |
| 7 | +The operator itself is built with the [Operator framework](https://github.com/operator-framework/operator-sdk). |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +* go version v1.12+. |
| 14 | +* Access to a Kubernetes v1.13.3 cluster. |
| 15 | + |
| 16 | +## Features |
| 17 | + |
| 18 | +- __Customize the number of master nodes and the number of replica nodes per master__ |
| 19 | + |
| 20 | +- __Password__ |
| 21 | + |
| 22 | +- __Safely Scaling the Redis Cluster__ |
| 23 | + |
| 24 | +- __Backup and Restore__ |
| 25 | + |
| 26 | +- __Persistent Volume__ |
| 27 | + |
| 28 | +- __Custom Configuration__ |
| 29 | + |
| 30 | +- __Prometheus Discovery__ |
| 31 | + |
| 32 | + |
| 33 | +## Quick Start |
| 34 | + |
| 35 | +### Deploy redis cluster operator |
| 36 | + |
| 37 | +Register the DistributedRedisCluster and RedisClusterBackup custom resource definition (CRD). |
| 38 | +``` |
| 39 | +$ kubectl create -f deploy/crds/redis.kun_distributedredisclusters_crd.yaml |
| 40 | +$ kubectl create -f deploy/crds/redis.kun_redisclusterbackups_crd.yaml |
| 41 | +``` |
| 42 | + |
| 43 | +A namespace-scoped operator watches and manages resources in a single namespace, whereas a cluster-scoped operator watches and manages resources cluster-wide. |
| 44 | +You can chose run your operator as namespace-scoped or cluster-scoped. |
| 45 | +``` |
| 46 | +// cluster-scoped |
| 47 | +$ kubectl create -f deploy/service_account.yaml |
| 48 | +$ kubectl create -f deploy/cluster/cluster_role.yaml |
| 49 | +$ kubectl create -f deploy/cluster/cluster_role_binding.yaml |
| 50 | +$ kubectl create -f deploy/cluster/operator.yaml |
| 51 | +
|
| 52 | +// namespace-scoped |
| 53 | +$ kubectl create -f deploy/service_account.yaml |
| 54 | +$ kubectl create -f deploy/namespace/role.yaml |
| 55 | +$ kubectl create -f deploy/namespace/role_binding.yaml |
| 56 | +$ kubectl create -f deploy/namespace/operator.yaml |
| 57 | +``` |
| 58 | + |
| 59 | +Verify that the redis-cluster-operator is up and running: |
| 60 | +``` |
| 61 | +$ kubectl get deployment |
| 62 | +NAME READY UP-TO-DATE AVAILABLE AGE |
| 63 | +redis-cluster-operator 1/1 1 1 1d |
| 64 | +``` |
| 65 | + |
| 66 | +#### Deploy a sample Redis Cluster |
| 67 | + |
| 68 | +``` |
| 69 | +$ kubectl apply -f deploy/example/redis.kun_v1alpha1_distributedrediscluster_cr.yaml |
| 70 | +``` |
| 71 | + |
| 72 | +Verify that the cluster instances and its components are running. |
| 73 | +``` |
| 74 | +$ kubectl get distributedrediscluster |
| 75 | +NAME MASTERSIZE STATUS AGE |
| 76 | +example-distributedrediscluster 3 Scaling 11s |
| 77 | +
|
| 78 | +$ kubectl get all -l redis.kun/name=example-distributedrediscluster |
| 79 | +NAME READY STATUS RESTARTS AGE |
| 80 | +pod/drc-example-distributedrediscluster-0 1/1 Running 0 4m5s |
| 81 | +pod/drc-example-distributedrediscluster-1 1/1 Running 0 3m31s |
| 82 | +pod/drc-example-distributedrediscluster-2 1/1 Running 0 2m54s |
| 83 | +pod/drc-example-distributedrediscluster-3 1/1 Running 0 2m20s |
| 84 | +pod/drc-example-distributedrediscluster-4 1/1 Running 0 103s |
| 85 | +pod/drc-example-distributedrediscluster-5 1/1 Running 0 62s |
| 86 | +
|
| 87 | +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 88 | +service/example-distributedrediscluster ClusterIP None <none> 6379/TCP,16379/TCP 4m5s |
| 89 | +
|
| 90 | +NAME READY AGE |
| 91 | +statefulset.apps/drc-example-distributedrediscluster 6/6 4m5s |
| 92 | +
|
| 93 | +$ kubectl get distributedrediscluster |
| 94 | +NAME MASTERSIZE STATUS AGE |
| 95 | +example-distributedrediscluster 3 Healthy 4m |
| 96 | +``` |
| 97 | + |
| 98 | +#### Scaling the Redis Cluster |
| 99 | + |
| 100 | +Increase the masterSize to trigger the scaling. |
| 101 | + |
| 102 | +``` |
| 103 | +apiVersion: redis.kun/v1alpha1 |
| 104 | +kind: DistributedRedisCluster |
| 105 | +metadata: |
| 106 | + name: example-distributedrediscluster |
| 107 | +spec: |
| 108 | + # Increase the masterSize to trigger the scaling. |
| 109 | + masterSize: 4 |
| 110 | + ClusterReplicas: 1 |
| 111 | + image: redis:5.0.4-alpine |
| 112 | +``` |
| 113 | + |
| 114 | +#### Backup and Restore |
| 115 | + |
| 116 | +Backup |
| 117 | +``` |
| 118 | +$ kubectl create -f deploy/example/backup-restore/redisclusterbackup_cr.yaml |
| 119 | +``` |
| 120 | + |
| 121 | +Restore from backup |
| 122 | +``` |
| 123 | +$ kubectl create -f deploy/example/backup-restore/restore.yaml |
| 124 | +``` |
| 125 | + |
| 126 | +#### Prometheus Discovery |
| 127 | + |
| 128 | +``` |
| 129 | +$ kubectl create -f deploy/example/prometheus-exporter.yaml |
| 130 | +``` |
| 131 | + |
| 132 | +#### Create Redis Cluster with password |
| 133 | + |
| 134 | +``` |
| 135 | +$ kubectl create -f deploy/example/custom-password.yaml |
| 136 | +``` |
| 137 | + |
| 138 | +#### Persistent Volume |
| 139 | + |
| 140 | +``` |
| 141 | +$ kubectl create -f deploy/example/persistent.yaml |
| 142 | +``` |
| 143 | + |
| 144 | +#### Custom Configuration |
| 145 | + |
| 146 | +``` |
| 147 | +$ kubectl create -f deploy/example/custom-config.yaml |
| 148 | +``` |
| 149 | + |
| 150 | +#### Custom Headless Service |
| 151 | + |
| 152 | +``` |
| 153 | +$ kubectl create -f deploy/example/custom-service.yaml |
| 154 | +``` |
| 155 | + |
| 156 | +#### Custom Resource |
| 157 | + |
| 158 | +``` |
| 159 | +$ kubectl create -f deploy/example/custom-resources.yaml |
| 160 | +``` |
0 commit comments