Skip to content

jimmidyson/kuisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

Running

Usage of ./build/kuisp:
  -c, --config-file=[]: The configuration files to create in the form "<template>=<output>"
  -p, --port=80: The port to listen on
  -s, --service=[]: The Kubernetes services to proxy to in the form "<prefix>=<serviceUrl>"
  -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}=${TEMPLATE}'

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •