Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions confd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ This folder contains examples of using Confd with StackEngine for an nginx rever

You can download confd from http://www.confd.io/. You may need to build confd with gb until the StackEngine backend is accepted into the new release.

Create 2 folders:
a) sudo mkdir /etc/confd
b) sudo mkdir /etc/confd/templates
c) sudo mkdir /etc/confd/conf.d
To build confd, you will need to install [gb](http://getgb.io) `go get github.com/constabulary/gb`

Place your *.tmpl files in the /etc/confd/templates folder and the *.toml files in the /etc/confd/conf.d directory.
Clone confd, cd to it and run `gb build all`

To start up confd using StackEngine as a backend, you can run this command:
To start up confd using StackEngine as a backend, you can run this command:

```
sudo ./bin/confd -backend stackengine -node <your_stackengine_node_url> -scheme https -auth-token <your_stackengine_auth_token>
sudo ./bin/confd -backend stackengine -confdir /path/to/examples/confd/haproxy -node <your_stackengine_node_url> -scheme https -auth-token <your_stackengine_auth_token>
```

Example:
```
sudo ./bin/confd -backend stackengine -node mesh-01:8443 -scheme https -auth-token 48de1cc472b6a81f
```

On the stackengine side, you can run this example with a docker image named "karthequian:helloworld/latest" saved as a component called "hello". At config time, map the stack to a dynamic port for the host, and container port to :80. You'll want to call your instance "i1". You can call this something else, but will need to update your toml and tmpl files to associate correctly with appropriate service discovery sections from StackEngine.
On the stackengine side, you can run this example with a docker image named "karthequian:helloworld/latest" saved as a component called "hello". At config time, map the stack to a dynamic port for the host, and container port to :80. You'll want to call your instance "i1". You can call this something else, but will need to update your toml and tmpl files to associate correctly with appropriate service discovery sections from StackEngine.

To configure haproxy for only one app, add it to the keys section of the `haproxy.toml` file. In this file, there is a commented line `perpool-wordpress-80`. Remove the line `"",` and uncomment this line. The resulting haproxy config should only list the containers up for the "perpool-wordpress-80" application.

Check HAproxy
HAProxy runs a stats page at ${HAPROXY_HOST}:1936. This is helpful for debugging your configuration.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# File location: sudo vim /etc/confd/conf.d/haproxy.toml

[template]
prefix = "apps"
src = "haproxy.cfg.tmpl"
dest = "/etc/haproxy/haproxy.cfg"
keys = [
"apps/i1-hello-80/containers",
"perpool-wordpress-80",
]
reload_cmd = "/usr/sbin/service haproxy reload"
62 changes: 0 additions & 62 deletions confd/haproxy/example_haproxy.cfg

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ backend nodes
balance roundrobin
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
# Iterate through all the keys from service discovery and place them in the format of "server <name> <ip> check" like you would in haproxy
{{range gets "/apps/i1-hello-80/containers/*"}}
server {{base .Key}} {{.Value}} check
{{end}}

{{range gets "/*/*/*"}}
server {{base .Key}} {{.Value}} check{{end}}

listen stats *:1936
stats enable
stats uri /haproxy?stats
stats hide-version
stats auth user:password
stats auth user:password