-
-
Save russparsloe/aee8d9ca05a1aceffc963b86928bab1d to your computer and use it in GitHub Desktop.
Consul B-Sides demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Recording of this webinar can be found here - https://www.hashicorp.com/resources/consul-b-sides-exploring-powerful-features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
consul-template -template "index.ctmpl:index.html:echo New webpage generated" -log-level=err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
consul agent -dev -config-file=./consul.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
consul kv put service/http/port 80 | |
consul kv put service/http/log_dir "/var/log/httpd/access_log" | |
consul kv put website/title "Dynamic configuration with Consul" | |
consul kv put website/content "Consul-Template is great!" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "HTTP port" | |
curl -s http://localhost:8500/v1/kv/service/http/port | jq | |
echo | |
index=$(curl -s http://localhost:8500/v1/kv/service/http/port | jq -r ".[].ModifyIndex") | |
echo "Waiting for changes" | |
curl -s http://localhost:8500/v1/kv/service/http/port?index=$index | jq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Watching for changes to log_dir" | |
consul watch -type=key -key=service/http/log_dir "jq -r .Value | base64 -D && echo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Creating event" | |
consul event -name broadcast "Sample Payload" | |
sleep 3 | |
consul watch -type=event -name=broadcast jq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for i in {1..5} | |
do | |
consul lock service/http/lock "echo Process $i has the lock && sleep 10 && echo Process $i has released the lock" & | |
done | |
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for i in {1..5} | |
do | |
consul lock -n=2 service/http/lock "echo Process $i has the lock && sleep 10 && echo Process $i has released the lock" & | |
done | |
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Checking uptime" | |
consul exec uptime | |
echo | |
sleep 5 | |
echo "Pinging Google DNS" | |
consul exec ping -c 5 8.8.8.8 | |
echo | |
sleep 5 | |
echo "Storing uptimes in K/V store" | |
consul exec 'consul kv put machines/$(hostname)/uptime "$(uptime)"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
consul-template -template "index.ctmpl:index.html:echo New webpage generated" -log-level=err -once |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"disable_remote_exec": false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>{{ key "website/title" }}</h1> | |
<p>We have a great webpage for you!</p> | |
<p>{{ key "website/content" }}</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment