Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to alpine 3.6 and consul to 1.0 #154

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions 1.0/consul-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM gliderlabs/consul:1.0
ADD ./config /config/
EXPOSE 8300 8301 8301/udp 8302 8302/udp 8400 8500 8600 8600/udp
ENV DNS_RESOLVES consul
ENV DNS_PORT 8600
ENTRYPOINT ["/bin/consul", "agent", "-config-dir=/config"]
3 changes: 3 additions & 0 deletions 1.0/consul-agent/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

build:
docker build -t gliderlabs/consul-agent:$(VERSION) .
9 changes: 9 additions & 0 deletions 1.0/consul-agent/config/agent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"client_addr": "0.0.0.0",
"data_dir": "/data",
"leave_on_terminate": true,
"dns_config": {
"allow_stale": true,
"max_stale": "1s"
}
}
3 changes: 3 additions & 0 deletions 1.0/consul-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM gliderlabs/consul-agent:1.0
ADD ./config /config/
ENTRYPOINT ["/bin/consul", "agent", "-server", "-config-dir=/config"]
3 changes: 3 additions & 0 deletions 1.0/consul-server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

build:
docker build -t gliderlabs/consul-server:$(VERSION) .
6 changes: 6 additions & 0 deletions 1.0/consul-server/config/server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ui": true,
"dns_config": {
"allow_stale": false
}
}
15 changes: 15 additions & 0 deletions 1.0/consul/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:3.6

ENV CONSUL_VERSION 1.0.0
ENV CONSUL_SHA256 585782e1fb25a2096e1776e2da206866b1d9e1f10b71317e682e03125f22f479

RUN apk --no-cache add curl ca-certificates \
&& curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip -o /tmp/consul.zip \
&& echo "${CONSUL_SHA256} /tmp/consul.zip" > /tmp/consul.sha256 \
&& sha256sum -c /tmp/consul.sha256 \
&& cd /bin \
&& unzip /tmp/consul.zip \
&& chmod +x /bin/consul \
&& rm /tmp/consul.zip

ENTRYPOINT ["/bin/consul"]
3 changes: 3 additions & 0 deletions 1.0/consul/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

build:
docker build -t gliderlabs/consul:$(VERSION) .
40 changes: 40 additions & 0 deletions 1.0/consul/update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -eo pipefail
[[ "$TRACE" ]] && set -x || :

debug() {
[[ "$DEBUG" ]] && echo "-----> $*" 1>&2
}

consul_version() {
sed -n "s/ENV CONSUL_VERSION //p" Dockerfile
}

next_version() {
debug "new version will be calculated ..."
local oldVersion=$(consul_version)
debug "oldVersion: $oldVersion"
echo ${oldVersion%.*}.$((${oldVersion##*.} + 1))
}

update_dockerfile() {
declare ver=${1:? required}

local sha=$(curl -Ls https://releases.hashicorp.com/consul/${ver}/consul_${ver}_SHA256SUMS | sed -n "s/ .*linux_amd64.*//p")
debug "sha=$sha"

sed -i "s/\(ENV CONSUL_VERSION\) .*/\1 $newVersion/;s/\(ENV CONSUL_SHA256\) .*/\1 $sha/" Dockerfile
}

main() {
declare desc="Updates Dockerfile url/sha for the provided version, or calculates next patch version if called without params"
declare newVersion=${1:-$(next_version)}

debug "newVersion=$newVersion"
update_dockerfile $newVersion
git diff
echo "=====> Now you can run: git commit -am 'Upgrade Consul to $newVersion'"
}

[[ "$0" == "$BASH_SOURCE" ]] && main "$@" || :
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=0.7
VERSION=1.0

build:
VERSION=$(VERSION) make -C $(VERSION)/consul
Expand Down
1 change: 1 addition & 0 deletions laboratory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# laboratory
Empty file added laboratory/consul/README.md
Empty file.
16 changes: 16 additions & 0 deletions laboratory/consul/exec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash -x

consul='consul'

### CONSUL SERVER MODE
docker run -d -p 8500:8500 --name $consul -h $consul progrium/consul -server -bootstrap

### GET IP CONSUL SERVER
JOIN_IP="$(docker inspect -f '{{.NetworkSettings.IPAddress}}' $consul)"

### SIMULATE ONE CONSUL AGENT MODE

for i in $(seq 1 3); do
docker run -d --name node${i} -h node${i} -v $PWD/node${i}.json:/config/consul.json progrium/consul -join $JOIN_IP
docker run -d --name apache${i} nimmis/alpine-apache
done
24 changes: 24 additions & 0 deletions laboratory/consul/node1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"leave_on_terminate": true,
"data_dir": "/data",
"ui_dir": "/ui",
"client_addr": "0.0.0.0",
"ports": {
"dns": 53
},
"recursor": "8.8.8.8",
"disable_update_check": true,

"service": {
"name": "pro_88888_apache",
"port": 80,
"tags": [
"apache",
"demonstration"
],
"check": {
"script": "curl 172.17.0.4:80 > /dev/null 2>&1",
"interval": "10s"
}
}
}
23 changes: 23 additions & 0 deletions laboratory/consul/node2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"data_dir": "/data",
"ui_dir": "/ui",
"client_addr": "0.0.0.0",
"ports": {
"dns": 53
},
"recursor": "8.8.8.8",
"disable_update_check": true,

"service": {
"name": "pro_88888_apache",
"port": 80,
"tags": [
"apache",
"demonstration"
],
"check": {
"script": "curl 172.17.0.6:80 > /dev/null 2>&1",
"interval": "10s"
}
}
}
23 changes: 23 additions & 0 deletions laboratory/consul/node3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"data_dir": "/data",
"ui_dir": "/ui",
"client_addr": "0.0.0.0",
"ports": {
"dns": 53
},
"recursor": "8.8.8.8",
"disable_update_check": true,

"service": {
"name": "pro_88888_apache",
"port": 80,
"tags": [
"apache",
"demonstration"
],
"check": {
"script": "curl 172.17.0.8:80 > /dev/null 2>&1",
"interval": "10s"
}
}
}