This repository has been archived by the owner on May 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for exposing the docker remote API
- Support exposing the Docker Remote API using TLS when certificates are provided - Add support for setting availability of the manager nodes on provisioning - Add timeout to docker join and docker leave commands. Avoid long waiting time in case a host cannot be reached - Add docker leave command when destroying a manager node, allows for down-scaling the amount of managers - Fix some issues with docker join bash scripting
- Loading branch information
Showing
11 changed files
with
225 additions
and
28 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ yum -y install docker-ce | |
|
||
sleep 1; | ||
|
||
systemctl enable docker | ||
systemctl start docker |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Install certificates for the Docker Remote API | ||
# Based on: | ||
# - https://coreos.com/os/docs/latest/customizing-docker.html | ||
# - https://docs.docker.com/engine/reference/commandline/dockerd/ | ||
# -https://docs.docker.com/engine/security/https/#secure-by-default | ||
|
||
sudo systemctl stop docker | ||
sudo systemctl disable docker | ||
|
||
sudo mkdir -p /var/ssl | ||
sudo mv ~/.docker/{server-cert.pem,server-key.pem,ca.pem} /var/ssl/ | ||
|
||
sudo cat<<-EOF > /etc/systemd/system/docker-tls-tcp.socket | ||
[Unit] | ||
Description=Docker Secured Socket for the API | ||
[Socket] | ||
ListenStream=2376 | ||
BindIPv6Only=both | ||
Service=docker.service | ||
[Install] | ||
WantedBy=sockets.target | ||
EOF | ||
|
||
sudo systemctl enable docker-tls-tcp.socket | ||
sudo systemctl stop docker | ||
sudo systemctl start docker-tls-tcp.socket | ||
|
||
sudo mkdir -p /etc/systemd/system/docker.service.d | ||
sudo cat<<-EOF > /etc/systemd/system/docker.service.d/10-tls-verify.conf | ||
[Service] | ||
Environment="DOCKER_OPTS=--tlsverify=true --tlscacert=/var/ssl/ca.pem --tlscert=/var/ssl/server-cert.pem --tlskey=/var/ssl/server-key.pem" | ||
EOF | ||
|
||
sudo systemctl daemon-reload | ||
sudo systemctl restart docker.service |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
sudo mkdir -p /var/ssl | ||
sudo mv ~/.docker/{server-cert.pem,server-key.pem,ca.pem} /var/ssl/ | ||
|
||
sudo mkdir -p /etc/systemd/system/docker.service.d | ||
sudo bash -c 'cat<<-EOF > /etc/systemd/system/docker.service.d/10-tls-verify.conf | ||
[Service] | ||
Environment="DOCKER_OPTS=--tlsverify=true --tlscacert=/var/ssl/ca.pem --tlscert=/var/ssl/server-cert.pem --tlskey=/var/ssl/server-key.pem" | ||
ExecStart= | ||
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix://var/run/docker.sock --tlsverify=true --tlscacert=/var/ssl/ca.pem --tlscert=/var/ssl/server-cert.pem --tlskey=/var/ssl/server-key.pem | ||
EOF' | ||
|
||
sudo systemctl daemon-reload | ||
sudo systemctl restart docker |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
MANAGER_PRIVATE_ADDR=$1 | ||
|
||
# Wait until Docker is running correctly | ||
while [ -z "$(${docker_cmd} info | grep CPUs)" ]; do | ||
echo Waiting for Docker to start... | ||
sleep 2 | ||
done | ||
|
||
${docker_cmd} swarm init --advertise-addr $MANAGER_PRIVATE_ADDR |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
MANAGER_PRIVATE_ADDR=$1 | ||
JOIN_TOKEN=$2 | ||
|
||
# Wait until Docker is running correctly | ||
while [ -z "$(${docker_cmd} info | grep CPUs)" ]; do | ||
echo Waiting for Docker to start... | ||
sleep 2 | ||
done | ||
|
||
# Check if we are not already joined into a Swarm | ||
if [ -z "$(${docker_cmd} info | grep 'Swarm: active')" ]; then | ||
# Join cluster | ||
${docker_cmd} swarm join --token $JOIN_TOKEN $MANAGER_PRIVATE_ADDR:2377; | ||
fi |
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