Giter Club home page Giter Club logo

kubernetes-twemproxy's Introduction

kubernetes-twemproxy

Running twemproxy on Kubernetes

General Overview

Deployments and Services for the redis nodes and twemproxy are found in their respective .yaml files in deployments/ and services/.

The port for twemproxy is 22121, and redis is 6379

quickReset.sh deletes all deployments and services for quicker development, and quickStart.sh starts up the redis nodes and twemproxies.

Upon starting up a twemproxy pod, twemproxy/run-twemproxy.sh is started. This starts the config monitor in the background and is responsible for starting the nutcracker/twemproxy process once a twemproxy.yaml file is created.

twemproxy/config-monitor.sh monitors any changes in the twemproxy config file that is generated by create-config.py. If the config file is different than the previous one, the twemproxy process is killed and restarted with the new config file.

create-config.py uses the kubernetes API to get all redis pods (identified by the label name: redis-node), and creates a temproxy config file with the IPs of each of those pods.

Creating the Pods

# Start the redis-node pods
kubectl create -f deployments/redis-node.yaml
kubectl create -f services/redis-node.yaml

# And start the twemproxy pods
kubectl create -f deployments/twemproxy.yaml
kubectl create -f services/twemproxy.yaml

Alternatively, just run quickStart.sh

Check the installation

To access twemproxy through the redis-cli:

kubectl port-forward [twemproxy-pod-name] 6379:22121

In a separate terminal:

redis-cli

# Check that it works:

127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
bar

To access a redis instance directly to test sharding:

kubectl port-forward [redis-node-pod-name] 6379:6379

If a redis-node pod is deleted, a new pod is created and twemproxy is restarted (if necessary) to use this new pod's IP.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.