Sign inSign up

svenmalvik/httpd

By svenmalvik

•Updated almost 10 years ago

... with consul-template

Image
0

1.9K

svenmalvik/httpd repository overview

------ PREPARATION --------- sudo yum install -y bind-utils dnsmasq

vi /etc/resolv.conf search localdomain nameserver 127.0.0.1 nameserver --the original--

vi /etc/dnsmasq.d/10-consul.conf server=/consul/127.0.0.1#8600 <<

docker run -d --name consul -p 8400:8400 -p 8500:8500 -p 8600:53/udp -h node1 progrium/consul -server -bootstrap -ui-dir /ui CONSUL=<HOST_IP>:8500 curl -X PUT $CONSUL/v1/kv/config/webapp/TEST -d "Dies ist ein Test"

------ END PREPARATION ---------

------ LIVE DEMO ---------

⁠Service Discovery

docker run -d -p 8080:80 --name helloworld svenmalvik/helloworld

CHANGEME: curl -X PUT -d '{ "ID": "helloworld","Name": "helloworld","Address": "<HOST_IP>","Port": 8080}' http://$CONSUL/v1/agent/service/register curl $CONSUL/v1/catalog/services curl $CONSUL/v1/catalog/service/helloworld dig @localhost -p 8600 helloworld.service.consul dig helloworld.service.consul

⁠Register DEMO

dig helloworld.service.consul SRV

⁠consul template

docker run -it -p 80:80 --name httpd --entrypoint bash --env CONSUL=$CONSUL svenmalvik/httpd vi /etc/consul-templates/app.conf.tmpl consul-template -consul=$CONSUL -template "/etc/consul-templates/app.conf.tmpl:/usr/local/apache2/conf/extra/app.conf:httpd -k restart" -once vi /usr/local/apache2/conf/extra/app.conf From browser: http://localhost⁠ docker stop helloworld httpd; docker rm helloworld httpd

⁠envconsul

docker run -it -p 8080:80 --name helloworld --entrypoint bash --env CONSUL=$CONSUL svenmalvik/helloworld /opt/envconsul -consul $CONSUL -sanitize -upcase -prefix config/webapp /go/bin/helloworld From browser: http://localhost:8080⁠ curl -X PUT $CONSUL/v1/kv/config/webapp/TEST -d "This is a test" From browser: http://localhost:8080⁠

⁠Clean up

curl -X DELETE $CONSUL/v1/agent/service/deregister/helloworld curl -X PUT $CONSUL/v1/kv/config/webapp/TEST -d "Dies ist ein Test" docker stop helloworld httpd; docker rm helloworld httpd ------ END OF LIVE DEMO ---------

Tag summary

Content type

Image

Digest

Size

120.4 MB

Last updated

almost 10 years ago

docker pull svenmalvik/httpd