Skip to content

Latest commit

 

History

History
83 lines (60 loc) · 3.22 KB

HOWTO.asciidoc

File metadata and controls

83 lines (60 loc) · 3.22 KB

How to use

Caution
the process described below contains many manual operations. This is both because it’s still early-wip and to keep a clear list of the steps for myself. But the goal is to get it progressively automated. I don’t like long lists of manual operations myself, rest assured :-).

(dm below is an alias for docker-machine)

Create a token using the hosted service (warning: not designed for production)

export SWARM_DISCOVERY=token://$(docker run --rm swarm create)

Create a swarm master

Note
binpack strategy is better for CI: this will keep room for bigger builds on remaining nodes. It’s also better when you want to downscale infra after a peak: it will indeed use a minimum number of machines.
dm create -d openstack \
          --swarm \
          --swarm-master \
          --swarm-strategy "binpack" \
          --swarm-discovery "$SWARM_DISCOVERY" \
          swarm-master
Tip
the recommended configuration is that the master be only the swarm manager, and not one of the cluster nodes. This is recommended for a production setup.
Caution
Before that issue is fixed, it’s not possible to provision a master not being also a node of the cluster. The workaround is to just run the command above to provision the machine in a standard, then connect to the machine and stop the node agent. (it may take a few seconds to a few minutes to propagate)
eval "$(docker-machine env swarm-master)"
docker stop swarm-agent
docker rm swarm-agent

Instantiate the Jenkins master

Locally, or in the cloud. For bandwidth & connectivity between master ⇐⇒ slaves reasons, might be better to put in the cloud too.

dm create -d openstack jenkins-master
export SWARM_MASTER_IP=$(dm ip swarm-master)
eval "$(docker-machine env jenkins-master)"
docker run -d \
           -e SWARM_MASTER_URL="https://$SWARM_MASTER_IP:3376" \
           -e DSL_REPO='https://github.com/batmat/jez-jobs.git' \
           -p 50000:50000 \
           -p 8080:8080 \
           --name jenkinsmaster \
           batmat/jez

You should now be able to browse the Jenkins instance at:

echo "Browse at http://$(dm ip jenkins-master):8080"

Copy the swarm-master `docker-machine’s directory (contains the certificates):

chmod -R ago+rX $HOME/.docker/machine/machines/swarm-master/
docker cp ~/.docker/machine/machines/swarm-master/ jenkinsmaster:/docker-certificates
Note
yeah, that part still feels like a hack. Gonna work on it. The chmod is called because docker cp will copy files as root with the local permissions. Hence, as Jenkins runtime runs under a dedicated jenkins user and not as root, that directory would be inaccessible.

The Job DSL project

Now, add as many nodes you want

dm create -d openstack \
          --swarm \
          --swarm-discovery "$SWARM_DISCOVERY" \
          swarm-node-1

…​