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
)
export SWARM_DISCOVERY=token://$(docker run --rm swarm create)
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
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
DSL_repo
parameter above is expected to be a Git URL, and -
The repository format is expected of the "standard" form of that example repository (maintained by one of the Job DSL committers) https://github.com/sheehan/job-dsl-gradle-example