A redis-operator based on operator-sdk (operator-sdk version v0.5.0+git)
- 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.
$ git clone https://github.com/kube-incubator/redis-operator.git
$ cd redis-operator
$ dep ensure
$ operator-sdk build shidaqiu/redis-operator:1.0
$ 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
$ 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
$ 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!"
If you are interested in contributing to the Redis-Operator project, feel free to send your Pull Request and Issue.