GithubHelp home page GithubHelp logo

magnifindinc / kuberneteshaproxynginx Goto Github PK

View Code? Open in Web Editor NEW
2.0 6.0 0.0 15 KB

a small program that helps us dynamically configure HAProxy with any change done in k8s.

Python 80.38% Shell 0.69% Smarty 18.93%

kuberneteshaproxynginx's Introduction

Kubernetes Dynamic Configuration for HAProxy and Nginx

Backround

at Magnifind.ca we are using Kubernetes under AWS. In order to save costs and keep our architecture simple and secure in some cases we are using HAproxy to balance within our internal services.

Kubernetes does not integrate with HAproxy so we needed to write a small program that will help us dynamically configure HAProxy/Nginx with any change done in k8s. The program writen in Python and support all versions.

We recommend using running the service under runit (We love runit!) since it's platform independant, simple fast and straight forward.

How is it working?

Very simple! The script pings Kubernetes API every 5 seconds, if anything changes in the relevant services or update with the nodes it will generate haproxy/nginx configuration and run a script. It will only look for services that is using NodePort

You might need to make small changes in the jinja template and your own script.

Installation and Configuration

Nothing fancy or complex... Install all the needed modules with pip and if you plan to query the API from remote machine make sure it's accessible.

You will need to add one more label (hostheader) to the service you want to load balance,

Here is an exmaple: "hostheader": "www.mydomain.tld"

Installing

git clone [email protected]:magnifindinc/KubernetesHAProxyNginx.git 
pip install -r requirements.txt

Example

./configureService.py --command ./dosomething.sh --api-server "http://my.kubernetes.localhost:8080" --interval 3 --proxy-type nginx

Contact

Feel free to fork, contribute or ask any quesion :) My Email address: [email protected]

kuberneteshaproxynginx's People

Contributors

adiri avatar

Stargazers

Michał Kułaczkowski avatar  avatar

Watchers

Bartłomiej Kossakowski avatar James Cloos avatar Nir avatar Michał Kokociński avatar Michał Kułaczkowski avatar  avatar

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.