diff --git a/README.md b/README.md index ba77f0f..78b3e1a 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,77 @@ Usage of ./haproxy-consul-connect: Consul ACL token./haproxy-consul-connect --help ``` +## Minimal working example + +You will need 2 SEPARATE servers within the same network, one for the server and another for the client. +On both you need all 3 binaries - consul, dataplaneapi and haproxy-consul-connect. + +### The services + +#### Server + +Create this config file for consul: +``` +{ + "service": { + "name": "server", + "port": 8181, + "connect": { "sidecar_service": {} } + } +} +``` +Run consul: +``` +consul agent -dev -config-file client.cfg +``` +Run the test server: +``` +python -m SimpleHTTPServer 8181 +``` +Run haproxy-connect (assuming that `haproxy` and `dataplaneapi` are $PATH): +``` +haproxy-consul-connect -sidecar-for server +``` + +#### Client + +Create this config file for consul: +``` +{ + "service": { + "name": "client", + "port": 8080, + "connect": { + "sidecar_service": { + "proxy": { + "upstreams": [ + { + "destination_name": "server", + "local_bind_port": 9191 + } + ] + } + } + } + } +} +``` +Run consul: +``` +consul agent -dev -config-file server.cfg +``` +Run haproxy-connect (assuming that `haproxy` and `dataplaneapi` in $PATH) : +``` +haproxy-consul-connect -sidecar-for client -log-level debug +``` + +### Testing + +On the server: +``` +curl -v 127.0.0.1:9191/ +``` + ## Contributing For commit messages and general style please follow the haproxy project's [CONTRIBUTING guide](https://github.com/haproxy/haproxy/blob/master/CONTRIBUTING) and use that where applicable.