Coder Social home page Coder Social logo

retocode / openshift-cross-cluster-loadbalancer Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 0.0 4.58 MB

A smart cross-cluster load balancer for OpenShift

License: Other

Go 73.67% HTML 0.74% Vue 18.57% JavaScript 7.03%
load-balancer openshift openshift-origin openshift-cluster

openshift-cross-cluster-loadbalancer's Introduction

OpenShift cross cluster load balancer

This is a tcp load balancer that is aware of multiple OpenShift clusters and their exported routes. Also uses pod filters to determine where a HA-Proxy is running. It is a prototype that was created during my masters thesis to prove an idea to update productive OpenShift clusters without any downtime and risk. The full thesis can be found here: Master Thesis

Screenshot

Image of the UI

Main idea

In a large, high load production OpenShift cluster, changes to cluster itself impose a huge risk. During two years of OpenShift operating experience the idea of a rolling update model for the hole OpenShift cluster formed. Basically this works the same way the rolling update of an application on OpenShift works, but instead of creating new containers, you create a hole new OpenShift cluster and automatically migrate the applications based on any selectors.

Rolling update of the cluster

In our case we would like to move less important projects to the new cluster, test all operations in productive workload and then migrate the important apps. As everything is containerized and based on yaml configuration files, the migration of applications is quite easy.

For us the missing part is an external load balancer that is aware of multiple OpenShift clusters and can balance to those based on which applications are exposed as routes.

This repo, the OpenShift "smart" load balancer fills that gap.

Smart load balancer components

Components of smart load balancer

High level overview

High level overview

Setup

  • You need two OpenShift clusters with HA-Proxies as routers
  • Install and run the smart load balancer on a server
  • Then install the smart load balancer plugin as a container on OpenShift:
# Prerequisite two OpenShift clusters with HA-Proxies

# Install the smart load balancer somewhere
# Get the binary from: https://github.com/ReToCode/openshift-cross-cluster-loadbalancer/releases
./openshift-cross-cluster-loadbalancer

# Deploy the plugin on multiple clusters
oc new-app retocode/origin:v3 --name=smart-lb-plugin -e SMART_LB_API_URLS=http://<ip-of-smart-lb>:8089 -e CLUSTER_KEY=openshift-1
oc new-app retocode/origin:v3 --name=smart-lb-plugin -e SMART_LB_API_URLS=http://ip-of-smart-lb:8089 -e CLUSTER_KEY=openshift-2

# Deploy some sample apps or use your own
# Cluster 1
oc project myproject
oc new-app retocode/node-sample:v2 —name=node-sample -e CLUSTER='OpenShift Cluster 1'
oc expose service node-sample --hostname=ose1-direct-myproject.192.168.99.100.nip.io
oc expose service node-sample --hostname=myapp.mydomain.com --name=shared-route
oc expose service node-sample --hostname=myapp-migrate.mydomain.com --name=shared-route-weight
oc annotate route shared-route-weight smartlb-weight='10'

# Cluster 2
oc project myproject
oc new-app retocode/node-sample:v2 --name=node-sample -e CLUSTER='OpenShift Cluster 2’
oc expose service node-sample --hostname=ose2-direct-myproject.192.168.99.103.nip.io
oc expose service node-sample --hostname=myapp.mydomain.com --name=shared-route
oc expose service node-sample --hostname=myapp-migrate.mydomain.com --name=shared-route-weight
oc annotate route shared-route-weight smartlb-weight='20'

# Check the UI on the smart load balancer http://<ip-of-smart-lb>:8089

# Get the apps directly
curl ose1-direct-myproject.192.168.99.100.nip.io
curl ose2-direct-myproject.192.168.99.103.nip.io

# Get the apps balanced
curl localhost:8080 -H 'Host: myapp.mydomain.com'

# Get the apps during a migration from one cluster to the other (weighted)
curl http://localhost:8080 -H 'Host: myapp-migrate.mydomain.com' 

openshift-cross-cluster-loadbalancer's People

Contributors

retocode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.