Skip to content

Latest commit

 

History

History
78 lines (61 loc) · 2.5 KB

README.md

File metadata and controls

78 lines (61 loc) · 2.5 KB

redis-operator

A redis-operator based on operator-sdk (operator-sdk version v0.5.0+git)

asciicast

Build

Prerequisites

  • dep version v0.5.0+.
  • git
  • go version v1.12+.
  • docker version 17.03+.
  • kubectl version v1.11.3+.
  • Access to a Kubernetes v1.11.3+ cluster.

Build redis-operator

$ git clone https://github.com/kube-incubator/redis-operator.git
$ cd redis-operator
$ dep ensure
$ operator-sdk build shidaqiu/redis-operator:1.0

Deploy

Deploy redis-operator

$ kubectl apply -f deploy/service_account.yaml
$ kubectl apply -f deploy/role.yaml
$ kubectl apply -f deploy/role_binding.yaml
$ kubectl apply -f deploy/crds/redis_v1alpha1_redis_crd.yaml
$ kubectl apply -f deploy/operator.yaml

Deploy sample redis cluster

$ kubectl apply -f deploy/samples/basic.yaml
$ kubectl get pod
NAME                                   READY   STATUS    RESTARTS   AGE
bc-redis-example-0                     1/1     Running   0          2m15s
bc-redis-example-1                     1/1     Running   0          93s
bc-redis-example-2                     1/1     Running   0          58s
bc-sentinel-example-6587886489-72zmr   1/1     Running   0          2m16s
bc-sentinel-example-6587886489-d2nlb   1/1     Running   0          2m16s
bc-sentinel-example-6587886489-wmfs7   1/1     Running   0          2m16s
redis-operator-799b6fdff-9q2w5         1/1     Running   0          2m27s

Connect to the redis cluster

$ kubectl exec -it $(kubectl get pod -l sentinel=example -o jsonpath='{.items[0].metadata.name}') -- redis-cli -p 26379 SENTINEL get-master-addr-by-name master
1) "172.17.0.8"
2) "6379"
$ kubectl exec -it $(kubectl get pod -l sentinel=example -o jsonpath='{.items[0].metadata.name}') -- redis-cli -h 172.17.0.8 -p 6379 SET hello world!
OK
$ kubectl exec -it $(kubectl get pod -l sentinel=example -o jsonpath='{.items[0].metadata.name}') -- redis-cli -h 172.17.0.8 -p 6379 GET hello
"world!"

Contribution

If you are interested in contributing to the Redis-Operator project, feel free to send your Pull Request and Issue.