Name: k8s-redis-ha
Owner: Hortonworks Inc
Description: Kubernetes Redis with High Availability
Forked from: keyki/k8s-redis-ha
Created: 2017-08-23 14:22:35.0
Updated: 2017-11-02 23:17:24.0
Pushed: 2018-01-08 13:58:11.0
Homepage: null
Size: 1770
Language: Shell
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Redis Images and Samples in this project are implemented using the latest features of Kubernetes:
If you already have a Kubernetes cluster, you can deploy High Availability Redis using the following command:
bectl create -f example/
ice "redis-sentinel" created
efulset "redis-sentinel" created
ice "redis-server" created
efulset "redis-server" created
"console" created
You can access Redis server using console
pod:
bectl exec -ti console -- /bin/bash
@console:# export MASTER_IP="$(redis-cli -h redis-sentinel -p 26379 sentinel get-master-addr-by-name mymaster | head -1)"
@console:# export SERVER_PASS="_redis-server._tcp.redis-server.default.svc.cluster.local"
@console:# redis-cli -h "${MASTER_IP}" -a "${SERVER_PASS}" set foo bar
@console:# redis-cli -h redis-server -a "${SERVER_PASS}" get foo
The passowrd is necessary for preventing independent Redis clusters from merging together in some circumstances.
With tarosky/k8s-redis-ha
, you can scale up/down Redis servers and Redis sentinels like the normal Deployment resources:
bectl scale --replicas=5 statefulset/redis-sentinel
efulset "redis-sentinel" scaled
bectl scale --replicas=5 statefulset/redis-server
efulset "redis-server" scaled
After these scale up/down, the expected number of available slaves in the Redis set are reset automatically.
bectl exec -ti console -- ipython
ython
1]: from redis import StrictRedis
2]: from redis.sentinel import Sentinel
3]: sentinel = Sentinel([
..: ('redis-sentinel-0.redis-sentinel.default.svc.cluster.local', 26379),
..: ('redis-sentinel-1.redis-sentinel.default.svc.cluster.local', 26379),
..: ('redis-sentinel-2.redis-sentinel.default.svc.cluster.local', 26379)
..: ], socket_timeout=0.1
..: )
4]: master = sentinel.master_for(
..: 'mymaster',
..: password='_redis-server._tcp.redis-server.default.svc.cluster.local',
..: socket_timeout=0.1
..: )
5]: slave = sentinel.slave_for(
..: 'mymaster',
..: password='_redis-server._tcp.redis-server.default.svc.cluster.local',
..: socket_timeout=0.1
..: )
6]: master.set('foo', 'bar')
6]: True
7]: slave.get('foo')
7]: b'bar'
venv .venv
urce .venv/bin/activate
p install -r test/requirements.txt
You can run the test command using the following command:
BE_NAMESPACE='{{Your name space}}' nosetests test/test.py