From ad06197b552c824da093b064f129a2477c04f92b Mon Sep 17 00:00:00 2001 From: Aric Renzo Date: Mon, 19 Jun 2017 10:59:11 -0400 Subject: [PATCH] Refactoring for using Docker behind a proxy --- README.md | 10 ++++++++++ genesis.sh | 42 ++++++++++++++++++++++++++++++++---------- join.sh | 42 ++++++++++++++++++++++++++++++++---------- 3 files changed, 74 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 1fc7ef56..e1b505a8 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,13 @@ vagrant ssh n3 -c 'sudo /vagrant/join.sh /vagrant/example/vagrant-config.yaml' ```bash docker build -t quay.io/attcomdev/promenade:experimental . ``` + +## Using Promenade Behind a Proxy + +Modify the `genesis.sh` and `proxy.sh` scripts, passing in the URL and ports of the proxy server relative to the cluster hosts: + +```bash +DOCKER_HTTP_PROXY="http://proxy.server.com:8080" +DOCKER_HTTPS_PROXY="https://proxy.server.com:8080" +DOCKER_NO_PROXY="localhost,127.0.0.1" +``` diff --git a/genesis.sh b/genesis.sh index d3f36304..4e0d3676 100755 --- a/genesis.sh +++ b/genesis.sh @@ -8,12 +8,15 @@ fi set -ex -#Set working directory relative to script -SCRIPT_DIR=$(dirname $0) -pushd $SCRIPT_DIR +#Promenade Variables +DOCKER_PACKAGE="docker.io" +DOCKER_VERSION=1.12.6-0ubuntu1~16.04.1 + +#Proxy Variables - set only if deploying behind a proxy +DOCKER_HTTP_PROXY="" +DOCKER_HTTPS_PROXY="" +DOCKER_NO_PROXY="" -#Load Variables File -. variables.sh mkdir -p /etc/docker cat < /etc/docker/daemon.json @@ -24,15 +27,34 @@ cat < /etc/docker/daemon.json EOS #Configuration for Docker Behind a Proxy -if [ $USE_PROXY == true ]; then - mkdir -p /etc/systemd/system/docker.service.d - CreateProxyConfiguraton -fi +mkdir -p /etc/systemd/system/docker.service.d + +#Set HTTPS Proxy Variable +cat < /etc/systemd/system/docker.service.d/http-proxy.conf +[Service] +Environment="HTTP_PROXY=${DOCKER_HTTPS_PROXY}" +EOF + +#Set HTTPS Proxy Variable +cat < /etc/systemd/system/docker.service.d/https-proxy.conf +[Service] +Environment="HTTPS_PROXY=${DOCKER_HTTPS_PROXY}" +EOF + +#Set No Proxy Variable +cat < /etc/systemd/system/docker.service.d/no-proxy.conf +[Service] +Environment="NO_PROXY=${DOCKER_NO_PROXY}" +EOF + +#Reload systemd and docker if present +systemctl daemon-reload +systemctl restart docker || true export DEBIAN_FRONTEND=noninteractive apt-get update -qq apt-get install -y -qq --no-install-recommends \ - docker.io=$DOCKER_VERSION \ + $DOCKER_PACKAGE=$DOCKER_VERSION \ if [ -f "${PROMENADE_LOAD_IMAGE}" ]; then diff --git a/join.sh b/join.sh index 8703b0dc..d0ea0d3b 100755 --- a/join.sh +++ b/join.sh @@ -8,12 +8,15 @@ fi set -ex -#Set working directory relative to script -SCRIPT_DIR=$(dirname $0) -pushd $SCRIPT_DIR +#Promenade Variables +DOCKER_PACKAGE="docker.io" +DOCKER_VERSION=1.12.6-0ubuntu1~16.04.1 + +#Proxy Variables - set only if deploying behind a proxy +DOCKER_HTTP_PROXY="" +DOCKER_HTTPS_PROXY="" +DOCKER_NO_PROXY="" -#Load Variables File -. variables.sh mkdir -p /etc/docker cat < /etc/docker/daemon.json @@ -24,15 +27,34 @@ cat < /etc/docker/daemon.json EOS #Configuration for Docker Behind a Proxy -if [ $USE_PROXY == true ]; then - mkdir -p /etc/systemd/system/docker.service.d - CreateProxyConfiguraton -fi +mkdir -p /etc/systemd/system/docker.service.d + +#Set HTTPS Proxy Variable +cat < /etc/systemd/system/docker.service.d/http-proxy.conf +[Service] +Environment="HTTP_PROXY=${DOCKER_HTTPS_PROXY}" +EOF + +#Set HTTPS Proxy Variable +cat < /etc/systemd/system/docker.service.d/https-proxy.conf +[Service] +Environment="HTTPS_PROXY=${DOCKER_HTTPS_PROXY}" +EOF + +#Set No Proxy Variable +cat < /etc/systemd/system/docker.service.d/no-proxy.conf +[Service] +Environment="NO_PROXY=${DOCKER_NO_PROXY}" +EOF + +#Reload systemd and docker if present +systemctl daemon-reload +systemctl restart docker || true export DEBIAN_FRONTEND=noninteractive apt-get update -qq apt-get install -y -qq --no-install-recommends \ - docker.io=$DOCKER_VERSION \ + $DOCKER_PACKAGE=$DOCKER_VERSION \ if [ -f "${PROMENADE_LOAD_IMAGE}" ]; then