Giter Site home page Giter Site logo

kuisp's Introduction

KUISP - Kubernetes UI & Service Proxy

KUISP (pronounced "kwisp") is a utility to simplify the serving of static HTML/JavaScript UIs, backed by possibly multiple RESTful API services. KUISP does the following:

  • serve static content from the speicified directory
  • use Golang templates to create configuration files from specified templates & environment variables
  • sets up reverse proxies to the specified services
  • http/2 server if TLS certificate/key is specified
  • configurable CA certificates for remote TLS services

The benefit this brings is that browser clients only need network access to the UI server, not the actual API servers.

Running

Usage of kuisp:
  -l, --access-logging=false: Enable access logging
      --ca-cert=[]: CA certs used to verify proxied server certificates
      --compress=false: Enable gzip/deflate response compression
  -c, --config-file=[]: The configuration files to create in the form "<template>=<output>"
  -d, --default-page="": Default page to send if page not found
      --max-age=0: Set the Cache-Control header for static content with the max-age set to this value, e.g. 24h. Must confirm to http://golang.org/pkg/time/#ParseDuration
  -p, --port=80: The port to listen on
  -s, --service=[]: The Kubernetes services to proxy to in the form "<prefix>=<serviceUrl>"
      --skip-cert-validation=false: Skip remote certificate validation - dangerous!
      --tls-cert="": Certificate file to use to serve using TLS
      --tls-key="": Certificate file to use to serve using TLS
  -w, --www=".": Directory to serve static files from
      --www-prefix="/": Prefix to serve static files on

Service proxying

For each service that you want to reverse proxy to, you can specify the -s or --service flag. The input to the flag must be in the format prefix=serviceUrl, e.g.

-s /db/=http://influxdb:8086/db/ -s /api/=http://apiserver:8080/api/v2/

As you can see you can specify the flag multiple times. You can also use environment variable expansion such as:

-s '/db/=http://${INFLUXDB_SERVICE_HOST}:${INFLUXDB_SERVICE_PORT}/db/'

Note the use of single quotes to ensure the environment variables don't get expanded in your shell before being passed to KUISP.

Configuration file templates

KUISP can process Golang templates into configuration files. KUISP can process multiple templates into multiple configuration files using the -c or --config-file flags. The configuration files & templates are specified in a similar fashion to the service definitions:

-c config.json.tmpl=config.json -c myconfig.ini.tmpl=/etc/myconfig.ini

Note that you can use relative or absolute paths for both templates & output files. Again, you can use environment variable expansion for any values:

-c '${TEMPLATE}=${OUTPUT}'

The only variables that are available in the template for processing are environment variables & are accessed like this:

{{ .Env.ENV_VAR_1 }}

As an example, the following template:

{
  "value": "{{ .Env.MY_VALUE }}"
}

When run with the environment variable MY_VALUE set to 3, would output:

{
  "value": "3"
}

Building

Just run make.

kuisp's People

Contributors

jimmidyson avatar rhuss avatar jstrachan avatar

Stargazers

Samuel Kelemen avatar Doru Carastan avatar Costin Grigore avatar 1StepEngineer avatar  avatar  avatar kingjcy avatar  avatar Flávio Ferreira avatar 唐飞雄 (twitter: @tangfx) avatar becile'memory avatar  avatar Adrià Galín Figueras avatar NCM avatar ZhaoBin avatar

Watchers

 avatar James Cloos avatar 唐飞雄 (twitter: @tangfx) avatar  avatar

kuisp's Issues

Support for having 404.html files in contexts for nested apps?

Just added /java/ to fabric8-console to split out all the java/jmx stuff into a separate app. Wondering if it'd be possible to support looking for 404.html files if a path on the disk can't be found, i.e. if I'm at http://localhost/java/jmx/attributes and click refresh I get index.html from the root context, whereas ideally I'd like to see if we can get the /java/404.html file served instead, otherwise you wind up back in the regular fabric8 console and not in the java console.

add support for websocket forwarding

when proxying the kubernetes REST API its looking like the websockets don't proxy yet

WebSocket connection to 'ws://k8s/api/v1/namespaces/default/pods?watch=true&access_token' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED

it'd be nice to be able to proxy those too

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.