From 6dd70200c309505d4f55a79de592bf8c1fec7b77 Mon Sep 17 00:00:00 2001 From: Greg Dubicki Date: Wed, 20 May 2020 14:57:32 +0200 Subject: [PATCH] Add minimal working example (credits to ShimmerGlass) based on https://github.com/haproxytech/haproxy-consul-connect/issues/5 --- README.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) 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.