collapse genesis and join code paths into one
This commit is contained in:
parent
712bbfca7a
commit
3d2b4ab8d6
|
@ -23,20 +23,20 @@ vagrant up
|
|||
Start the genesis node:
|
||||
|
||||
```bash
|
||||
vagrant ssh n0 -c 'sudo /vagrant/genesis.sh /vagrant/configs/n0.yaml'
|
||||
vagrant ssh n0 -c 'sudo /vagrant/up.sh /vagrant/configs/n0.yaml'
|
||||
```
|
||||
|
||||
Join the master nodes:
|
||||
|
||||
```bash
|
||||
vagrant ssh n1 -c 'sudo /vagrant/join.sh /vagrant/configs/n1.yaml'
|
||||
vagrant ssh n2 -c 'sudo /vagrant/join.sh /vagrant/configs/n2.yaml'
|
||||
vagrant ssh n1 -c 'sudo /vagrant/up.sh /vagrant/configs/n1.yaml'
|
||||
vagrant ssh n2 -c 'sudo /vagrant/up.sh /vagrant/configs/n2.yaml'
|
||||
```
|
||||
|
||||
Join the worker node:
|
||||
|
||||
```bash
|
||||
vagrant ssh n3 -c 'sudo /vagrant/join.sh /vagrant/configs/n3.yaml'
|
||||
vagrant ssh n3 -c 'sudo /vagrant/up.sh /vagrant/configs/n3.yaml'
|
||||
```
|
||||
|
||||
### Development Cleanup
|
||||
|
@ -50,8 +50,7 @@ find the `cleanup.sh` script useful.
|
|||
docker build -t promenade:local .
|
||||
```
|
||||
|
||||
For development, you may wish to save it and have the `genesis.sh` and
|
||||
`join.sh` scripts load it:
|
||||
For development, you may wish to save it and have the `up.sh` script load it:
|
||||
|
||||
```bash
|
||||
docker save -o promenade.tar promenade:local
|
||||
|
@ -60,7 +59,7 @@ docker save -o promenade.tar promenade:local
|
|||
Then on a node:
|
||||
|
||||
```bash
|
||||
PROMENADE_LOAD_IMAGE=/vagrant/promenade.tar /vagrant/genesis.sh /vagrant/path/to/node-config.yaml
|
||||
PROMENADE_LOAD_IMAGE=/vagrant/promenade.tar /vagrant/up.sh /vagrant/path/to/node-config.yaml
|
||||
```
|
||||
|
||||
To build the image from behind a proxy, you can:
|
||||
|
@ -81,5 +80,5 @@ cd /vagrant
|
|||
export DOCKER_HTTP_PROXY="http://proxy.server.com:8080"
|
||||
export DOCKER_HTTPS_PROXY="https://proxy.server.com:8080"
|
||||
export DOCKER_NO_PROXY="localhost,127.0.0.1"
|
||||
sudo -E /vagrant/genesis.sh /vagrant/configs/n0.yaml
|
||||
sudo -E /vagrant/up.sh /vagrant/configs/n0.yaml
|
||||
```
|
||||
|
|
81
genesis.sh
81
genesis.sh
|
@ -1,81 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "This script must be run as root." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "x$1" = "x" ]; then
|
||||
echo "Path to node configuration required." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -ex
|
||||
|
||||
#Promenade Variables
|
||||
PROMENADE_TAG=${PROMENADE_TAG:-latest}
|
||||
PROMENADE_IMAGE=${PROMENADE_IMAGE:-quay.io/attcomdev/promenade:${PROMENADE_TAG}}
|
||||
DOCKER_PACKAGE=${DOCKER_PACKAGE:-docker.io}
|
||||
DOCKER_VERSION=${DOCKER_VERSION:-1.12.6-0ubuntu1~16.04.1}
|
||||
|
||||
#Proxy Variables
|
||||
DOCKER_HTTP_PROXY=${DOCKER_HTTP_PROXY:-${HTTP_PROXY:-${http_proxy}}}
|
||||
DOCKER_HTTPS_PROXY=${DOCKER_HTTPS_PROXY:-${HTTPS_PROXY:-${https_proxy}}}
|
||||
DOCKER_NO_PROXY=${DOCKER_NO_PROXY:-${NO_PROXY:-${no_proxy}}}
|
||||
|
||||
|
||||
mkdir -p /etc/docker
|
||||
cat <<EOS > /etc/docker/daemon.json
|
||||
{
|
||||
"live-restore": true,
|
||||
"storage-driver": "overlay2"
|
||||
}
|
||||
EOS
|
||||
|
||||
#Configuration for Docker Behind a Proxy
|
||||
mkdir -p /etc/systemd/system/docker.service.d
|
||||
|
||||
#Set HTTPS Proxy Variable
|
||||
cat <<EOF > /etc/systemd/system/docker.service.d/http-proxy.conf
|
||||
[Service]
|
||||
Environment="HTTP_PROXY=${DOCKER_HTTP_PROXY}"
|
||||
EOF
|
||||
|
||||
#Set HTTPS Proxy Variable
|
||||
cat <<EOF > /etc/systemd/system/docker.service.d/https-proxy.conf
|
||||
[Service]
|
||||
Environment="HTTPS_PROXY=${DOCKER_HTTPS_PROXY}"
|
||||
EOF
|
||||
|
||||
#Set No Proxy Variable
|
||||
cat <<EOF > /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_PACKAGE=$DOCKER_VERSION \
|
||||
|
||||
|
||||
if [ -f "${PROMENADE_LOAD_IMAGE}" ]; then
|
||||
echo === Loading updated promenade image ===
|
||||
docker load -i "${PROMENADE_LOAD_IMAGE}"
|
||||
fi
|
||||
|
||||
docker run -t --rm \
|
||||
--net host \
|
||||
-v /:/target \
|
||||
${PROMENADE_IMAGE} \
|
||||
promenade \
|
||||
-v \
|
||||
genesis \
|
||||
--hostname $(hostname) \
|
||||
--config-path /target$(realpath $1) 2>&1
|
||||
|
||||
touch /var/lib/prom.done
|
|
@ -25,34 +25,13 @@ def promenade(*, verbose):
|
|||
type=click.Path(exists=True, file_okay=False,
|
||||
dir_okay=True, resolve_path=True),
|
||||
help='Location where templated files will be placed.')
|
||||
def genesis(*, asset_dir, config_path, hostname, target_dir):
|
||||
def up(*, asset_dir, config_path, hostname, target_dir):
|
||||
|
||||
op = operator.Operator.from_config(config_path=config_path,
|
||||
hostname=hostname,
|
||||
target_dir=target_dir)
|
||||
|
||||
op.genesis(asset_dir=asset_dir)
|
||||
|
||||
|
||||
@promenade.command(help='Join an existing cluster')
|
||||
@click.option('-a', '--asset-dir', default='/assets',
|
||||
type=click.Path(exists=True, file_okay=False,
|
||||
dir_okay=True, resolve_path=True),
|
||||
help='Source path for binaries to deploy.')
|
||||
@click.option('-c', '--config-path', type=click.File(),
|
||||
help='Location of cluster configuration data.')
|
||||
@click.option('--hostname', help='Current hostname.')
|
||||
@click.option('-t', '--target-dir', default='/target',
|
||||
type=click.Path(exists=True, file_okay=False,
|
||||
dir_okay=True, resolve_path=True),
|
||||
help='Location where templated files will be placed.')
|
||||
def join(*, asset_dir, config_path, hostname, target_dir):
|
||||
|
||||
op = operator.Operator.from_config(config_path=config_path,
|
||||
hostname=hostname,
|
||||
target_dir=target_dir)
|
||||
|
||||
op.join(asset_dir=asset_dir)
|
||||
op.up(asset_dir=asset_dir)
|
||||
|
||||
|
||||
@promenade.command(help='Generate certs and keys')
|
||||
|
|
|
@ -19,13 +19,7 @@ class Operator:
|
|||
self.hostname = hostname
|
||||
self.target_dir = target_dir
|
||||
|
||||
def genesis(self, *, asset_dir=None):
|
||||
self.setup(asset_dir=asset_dir)
|
||||
|
||||
def join(self, *, asset_dir=None):
|
||||
self.setup(asset_dir=asset_dir)
|
||||
|
||||
def setup(self, *, asset_dir):
|
||||
def up(self, *, asset_dir):
|
||||
self.rsync_from(asset_dir)
|
||||
self.render()
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ docker run -t --rm \
|
|||
${PROMENADE_IMAGE} \
|
||||
promenade \
|
||||
-v \
|
||||
join \
|
||||
up \
|
||||
--hostname $(hostname) \
|
||||
--config-path /target$(realpath $1) 2>&1
|
||||
|
Loading…
Reference in New Issue