tarosky / K8s Redis Ha
Licence: mit
Kubernetes Redis with High Availability
Stars: ✭ 127
Programming Languages
shell
77523 projects
Labels
Projects that are alternatives of or similar to K8s Redis Ha
Distributed framework
python通用分布式函数调度框架 pip install function_scheduling_distributed_framework
Stars: ✭ 123 (-3.15%)
Mutual labels: redis
Sensu Ansible
An Ansible role to deploy a fully dynamic Sensu stack!
Stars: ✭ 126 (-0.79%)
Mutual labels: redis
Simpleue
PHP queue worker and consumer - Ready for AWS SQS, Redis, Beanstalkd and others.
Stars: ✭ 124 (-2.36%)
Mutual labels: redis
Cash
HTTP response caching for Koa. Supports Redis, in-memory store, and more!
Stars: ✭ 122 (-3.94%)
Mutual labels: redis
Vertx Kue
Vert.x Blueprint Project - Vert.x Kue, a priority task queue powered by Vert.x
Stars: ✭ 126 (-0.79%)
Mutual labels: redis
Uexam Mysql
学之思在线考试系统,支持多种题型:选择题、多选题、判断题、填空题、解答题以及数学公式,包含PC端、小程序端,扩展性强,部署方便、界面设计友好、代码结构清晰
Stars: ✭ 124 (-2.36%)
Mutual labels: redis
Redis Game Transaction
在大型游戏中经常使用分布式,分布式中因为游戏逻辑会经常游戏事务,借助redis特性我们可以实现分布式锁和分布式事务。很多redis集群不支持redis的事务特性。 这个框架用来解决分布式服务器下redis集群事务失效的情况下,基于分布式锁完成分布式事务。支持独占锁,共享锁,读写锁,并且支持事务提交失败情况下的回滚操作,让开发者可以有更多时间侧重游戏逻辑.
Stars: ✭ 124 (-2.36%)
Mutual labels: redis
Redli
Redli - A humane alternative to the Redis-cli and TLS
Stars: ✭ 126 (-0.79%)
Mutual labels: redis
Tornadis
async minimal redis client for tornado ioloop designed for performances (use C hiredis parser)
Stars: ✭ 126 (-0.79%)
Mutual labels: redis
Android Notes
Articles, notes, interview questions and resources management for Android.
Stars: ✭ 126 (-0.79%)
Mutual labels: redis
Kubernetes Redis with High Availability
Redis Images and Samples in this project are implemented using the latest features of Kubernetes:
- StatefulSet
- Init Container
Requirements
- Kubernetes 1.6 cluster
- Redis 3.2
Quick Start
If you already have a Kubernetes cluster, you can deploy High Availability Redis using the following command:
$ kubectl create -f example/
service "redis-sentinel" created
statefulset "redis-sentinel" created
service "redis-server" created
statefulset "redis-server" created
pod "console" created
Accessing Redis
You can access Redis server using console
pod:
$ kubectl exec -ti console -- /bin/bash
export MASTER_IP="$(redis-cli -h redis-sentinel -p 26379 sentinel get-master-addr-by-name mymaster | head -1)"
export SERVER_PASS="_redis-server._tcp.redis-server.default.svc.cluster.local"
-h "${MASTER_IP}" -a "${SERVER_PASS}" set foo bar
OK
-h redis-server -a "${SERVER_PASS}" get foo
bar
The passowrd is necessary for preventing independent Redis clusters from merging together in some circumstances.
Scale Up and Down
With tarosky/k8s-redis-ha
, you can scale up/down Redis servers and Redis sentinels like the normal Deployment resources:
$ kubectl scale --replicas=5 statefulset/redis-sentinel
statefulset "redis-sentinel" scaled
$ kubectl scale --replicas=5 statefulset/redis-server
statefulset "redis-server" scaled
After these scale up/down, the expected number of available slaves in the Redis set are reset automatically.
Sample Code in Python
$ kubectl exec -ti console -- ipython
In [1]: from redis import StrictRedis
In [2]: from redis.sentinel import Sentinel
In [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
...: )
In [4]: master = sentinel.master_for(
...: 'mymaster',
...: password='_redis-server._tcp.redis-server.default.svc.cluster.local',
...: socket_timeout=0.1
...: )
In [5]: slave = sentinel.slave_for(
...: 'mymaster',
...: password='_redis-server._tcp.redis-server.default.svc.cluster.local',
...: socket_timeout=0.1
...: )
In [6]: master.set('foo', 'bar')
Out[6]: True
In [7]: slave.get('foo')
Out[7]: b'bar'
Running the Test Script
$ pyvenv .venv
$ source .venv/bin/activate
$ pip install -r test/requirements.txt
You can run the test command using the following command:
$ KUBE_NAMESPACE='{{Your name space}}' nosetests test/test.py
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].