Name: kubernetes-dns-reverse-proxy
Owner: NYT Newsroom Developers
Description: Proxy server to route traffic to the right kubernetes local hostname
Created: 2015-10-01 17:46:30.0
Updated: 2016-11-30 20:13:52.0
Pushed: 2017-01-30 16:57:15.0
Size: 588
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A web server to route requests in a Kubernetes cluster to a corresponding Service based upon routes describes in a JSON configuration file.
Itself runs as a container within a kubernetes cluster with the path to the configuration file and options passed as command-line arguments.
--domain-suffixes
Domain suffixes, comma separated. Default: .local
--kubernetes-dns-domain
Kubernetes DNS domain. Default: cluster.local
--kubernetes-namespace
Kubernetes namespace to server. Default: default
--static
Whether to enable the proxy to serve content from a static file server. Default: false
--static-scheme
Scheme of the static file server. Default: http
--static-host
Hostname of the static file server. Default: ``
--static-path
Path prefix of the static file server. Default: /
--fallback
Whether to enable a fallback proxy. Default: false
--fallback-scheme
Fallback scheme. Default: http
--fallback-host
Fallback host. Default: ``
--fallback-path
Fallback path. Default: /
--routes
Absolute path to the routes file. Default: ``
--concurrency
concurrency per host. Default: 32
--timeout
dial timeout.
To log stats to Datadog, set the DD_AGENT_SERVICE_HOST_PORT
environment variable.
The routes.json
file is a JSON object with hostnames as top-level keys. Each hostname references an object with path prefixes as keys. Each path prefix is a key to a pattern.
xample.com": {
"/": "<pattern>"
Possible patterns are as follows.
| pattern | result | example |
| ——– | ——– | ——- |
| myservice
| Routed to a kubernetes service | “myservice” routed to myservice.<kubernetes-namespace>.<kubernetes-dns-domain>
|
| /static_dir
| Routed to a static host like S3 | “/static_dir” routed to <static-host>/<static-path>/request_path
|
Rf ./Godeps
Rf ./vendor
et ./...
et -u ./...
p save ./...
p update ./...
There's a shell script to get a local server running. First set up your $GOPATH
, then clone the repo into $GOPATH/src/github.com/newsdev/kubernetes-dns-reverse-proxy
rt GOPATH=~/gocode
r -p $GOPATH/src/github.com/newsdev/
GOPATH/src/github.com/newsdev
clone git@github.com:newsdev/kubernetes-dns-reverse-proxy.git
ubernetes-dns-reverse-proxy
st/demo.sh
This boots a copy of the kubernetes-dns-reverse-proxy server on localhost:8080, and the test server on localhost:8090 (this echos back the Host
heeader provided).
Hit http://www.127.0.0.1.xip.io:8080/projects/app1 and check your local logs. You'll see this route to service1 as specified in the routes.
Try http://www.127.0.0.1.xip.io:8080/projects/app2. This should route to service 2.
est ./...
TK