Skip to content

Instantly share code, notes, and snippets.

@0xIslamTaha
Last active February 7, 2019 11:27
Show Gist options
  • Save 0xIslamTaha/6691ab9bf8f6ce400a3255bff102027f to your computer and use it in GitHub Desktop.
Save 0xIslamTaha/6691ab9bf8f6ce400a3255bff102027f to your computer and use it in GitHub Desktop.

#pre-requests: There should be a running etcd server with api v3 and an authontication. The following script can do that for you

wget https://github.com/etcd-io/etcd/releases/download/v3.3.11/etcd-v3.3.11-linux-amd64.tar.gz
tar -xzfv etcd-v3.3.11-linux-amd64.tar.gz
cp etcd-v3.3.11-linux-amd64/etcd /usr/bin
cp etcd-v3.3.11-linux-amd64/etcdctl /usr/bin
export ETCDCTL_API="3"
etcd&
etcdctl user add root:root
etcdctl auth enable

To create a webgateway proxy, follow the following steps using jsx dev:

coredns = j.clients.coredns.get('coredns', host="127.0.0.1", port=2379, user="root", password_="root") 
etcd = j.clients.etcd.get('etcd_test2', host="127.0.0.1", port=2379, user="root", password_="root")
traefik = j.clients.traefik.get('traefik', host="127.0.0.1", port=2379, user="root", password_="root", etcd_instance="etcd_test2") 
webgateway = j.clients.webgateway.get(name='webgateway', etcd_instance='etcd_test2')
webgateway.service_create(name='test')
service.expose('superblog.com', ['http://192.168.1.10:8080'])

By checking the etcd records, we can find our config

root@d8fc9d023517:~# etcdctl get --from-key '' --user root:root
/traefik/backends/test/loadBalancer/method
wrr
/traefik/backends/test/servers/server0/url
http://192.168.1.10:8080
/traefik/backends/test/servers/server0/weight
10
/traefik/frontends/test/backend
test
/traefik/frontends/test/routes/rule0/rule
Host:superblog.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment