As a member of DevOps team, I want to stand up DevOps tools (Platform as Code) so that projects can run Coninious Integration / Delivery
Docker swarm mode environment is required
- Use provided
Vagrantfileif you are unable to run Docker CE natively on a local machine - OR see Docker on AWS documentation on how to create a Docker swarm cluster on AWS
The assumption here is that Vagrant, Virtual Box and Gitbash are already install on your machine
- Log into the master node in the Docker Swarm mode cluster
vagrant ssh - Clone this repository
git clone https://github.com/shazChaudhry/docker-swam-mode.git - Change directory
cd docker-swam-mode - Deploy stack by run the following commands which will utilize Docker secrets
echo "admin" | docker secret create jenkins-user - echo "admin" | docker secret create jenkins-pass - docker stack deploy --compose-file docker-compose.yml ci - Check status of the stack services by running the following command:
docker stack services ci
- Once all services are up and running, proceed to testing
- http://node1:9999 (Visualizer)
- http://node1/jenkins (Jenkins). admin username:
admin; Password:admin - http://node1/sonar (SonarQube). admin username:
admin; Password:admin - http://node1/nexus (Nexus). admin username:
admin; Password:admin123 - http://node1/gitlab (Gitlab CE). admin username:
admin@example.com; Password:5iveL!fe- Gitlab takes a few minutes to become available so please be a little patient :)
On the swarm master node, run the following commands:
docker stack rm cito remove the stackexitto exit the Virtual Boxvagrant destroyto destroy the VMs
It is assumed you have followed Docker for AWS documentation to create a new VPC. Follow these commands in an ssh client to log into your master node (I'm using gitbash).
Please note you can not ssh directly into worker nodes. You have to use a manager node as a jump box
eval $(ssh-agent) OR exec ssh-agent bash
ssh-add -k ~/.ssh/personal.pem
ssh-add -L
ssh -A docker@<Manager Public IP>
cat /etc/*-release
docker node ls
Note:
If Jenkins in this stack is unable to run sibling containers, set appropriate permission:
sudo setfacl -m u:1000:rw /var/run/docker.sockon all nodes. If this command fails then a workround issudo chmod 666 /var/run/docker.sockon all nodes
Clone this repo and change directory by following these commands
alias git='docker run -it --rm --name git -v $PWD:/git -w /git indiehosters/git git'
git version
git clone https://github.com/shazChaudhry/docker-swam-mode.git
sudo chown -R $USER docker-swam-mode
cd docker-swam-mode
Start the visualizer by running:
docker stack deploy -c docker-compose.visualizer.yml visualizer
In a Docker swarm mode, only a single Compose file is accepted. If your configuration is split between multiple Compose files, e.g. a base configuration and environment-specific overrides, you can combine these by passing them to docker-compose config with the -f option and redirecting the merged output into a new file.
alias docker-compose='docker run --interactive --tty --rm --name docker-compose --volume $PWD:/compose --workdir /compose docker/compose:1.16.1'
docker-compose version
docker-compose -f docker-compose.yml -f docker-compose.AWS.cloudstor.yml config > docker-stack.yml
You may be interested in knowing that the generated stack defines a volume plugin called Cloudstor. Docker containers can use a volume created with Cloudstor (available across entire cluster) to mount a persistent data volume
Run the combined stack
echo "admin" | docker secret create jenkins-user -
echo "admin" | docker secret create jenkins-pass -
docker stack deploy --compose-file docker-stack.yml ci
If in case the above "stack deploy" does not work and throws an error like yaml: control characters are not allowed
- SOLUTION 1:- Open the generated "docker-stack.yml" file and delete the first line starting with a WARNING
- SOLUTION 2:- Ensure that the source path for settings.xml file mounted into jenkins' container is correct
- http://[DefaultDNSTarget]:9999 (Visualizer)
- http://[DefaultDNSTarget]/jenkins (Jenkins). admin username:
admin; Password:admin - http://[DefaultDNSTarget]/sonar> (SonarQube). admin username:
admin; Password:admin - http://[DefaultDNSTarget]/nexus (Nexus). admin username:
admin; Password:admin123 - http://[DefaultDNSTarget]/gitlab (Gitlab CE). admin username:
admin@example.com; Password:5iveL!fe- Gitlab takes a few minutes to become available so please be a little patient :)
- You find [DefaultDNSTarget] on the CloudFormation page on the Outputs tab
docker stack rm ciswarm-exec docker system prune --volumes -a- Before deleting a Docker4AWS stack through CloudFormation, you should remove all relocatable Cloudstor volumes using docker volume rm from within the stack. EBS volumes corresponding to relocatable Cloudstor volumes are not automatically deleted as part of the CloudFormation stack deletion
