Talk materials, links, snippets and a simple ansible playbook as showcase
Link to the Slides: Running Spring Boot Apps on Docker Windows Containers with Ansible.pdf
https://github.com/jonashackt/ansible-windows-docker-springboot
https://github.com/jonashackt/cxf-spring-cloud-netflix-docker
https://blog.codecentric.de/en/2017/01/ansible-windows-spring-boot/
https://blog.codecentric.de/en/2017/04/ansible-docker-windows-containers-spring-boot/
https://www.heise.de/developer/artikel/Docker-Windows-Container-mit-Ansible-managen-1-2-3824736.html
https://www.heise.de/developer/artikel/Docker-Windows-Container-mit-Ansible-managen-2-2-3838642.html
https://docs.microsoft.com/en-us/virtualization/windowscontainers/index
This is a step that requires to download ~10GB and takes quite long to complete - if you want to follow the demo live @ the talk, you should prepare the hole step at home.
if you´re on a Mac, this can easily be accomplished via brew
brew cask install virtualbox
brew cask install vagrant
brew install packer
- (Java part only)
brew install maven
on Windows, take chocolatey
choco install virtualbox
choco install vagrant
choco install packer
- (Java part only)
choco install maven
https://www.microsoft.com/de-de/evalcenter/evaluate-windows-server-2016 (registration needed)
Clone this GitHub repo ansible-windows-docker-springboot, cd into it and the subfolder step0-packer-windows-vagrantbox
. Then run:
packer build -var iso_url=14393.0.161119-1705.RS1_REFRESH_SERVER_EVAL_X64FRE_EN-US.ISO -var iso_checksum=70721288bbcdfe3239d8f8c0fae55f1f windows_server_2016_docker.json
vagrant init windows_2016_docker_virtualbox.box
Now fire up your Windows Server 2016 box:
vagrant up
You can check if everything is ok as a last step if you cd into ansible-windows-simple and run a
ansible windows-dev -i hostsfile -m win_ping
- which should give anSUCCESS
Find more info here: https://github.com/jonashackt/ansible-windows-docker-springboot#build-your-windows-server-2016-vagrant-box
cd into ansible-windows-simple and test the connection first:
ansible windows-dev -i hostsfile -m win_ping
Then run the playbook:
ansible-playbook -i hostsfile windows-playbook.yml --extra-vars "host=windows-dev"
cd into step1-prepare-docker-windows
ansible-playbook -i hostsfile prepare-docker-windows.yml --extra-vars "host=ansible-windows-docker-springboot-dev"
docker run --name dotnetbot microsoft/dotnet-samples:dotnetapp-nanoserver
Clone example application´s repository cxf-spring-cloud-netflix-docker, cd into weatherbackend & do a:
mvn clean package
Then cd into weatherbackend/target
java -jar weatherbackend-0.0.1-SNAPSHOT.jar
Go to localhost:8090/swagger-ui.html and do a GET onto weather-backend-controller /weather/{name}
cd into step2-single-spring-boot-app and run the playbook:
ansible-playbook -i hostsfile ansible-windows-docker-springboot.yml --extra-vars "host=ansible-windows-docker-springboot-dev app_name=weatherbackend jar_input_path=../../cxf-spring-cloud-netflix-docker/weatherbackend/target/weatherbackend-0.0.1-SNAPSHOT.jar"
Show running Docker containers:
docker ps -a
Show logs of running container:
docker logs simpleapp_weatherbackend
Connect into running container with Powershell:
docker exec -it simpleapp_weatherbackend powershell
Show some environment variables:
Get-ChildItem Env:
Call webserver:
iwr http://localhost:8090/swagger-ui.html -UseBasicParsing
Find container´s IP:
docker network inspect nat
Go to containerIP:8088/swagger-ui.html and try it out again!
Example project cxf-spring-cloud-netflix-docker
More info on this blog post https://blog.codecentric.de/en/2017/05/ansible-docker-windows-containers-scaling-spring-cloud-netflix-docker-compose/
cd into step3-multiple-spring-boot-apps-docker-compose
ansible-playbook -i hostsfile ansible-windows-docker-springboot.yml --extra-vars "host=ansible-windows-docker-springboot-dev"
Show running Docker containers:
docker ps -a
Look for eureka-serviceregistry Container´s IP
docker network inspect nat
and go to eurekaIP:8761
Go to http://localhost:48080/routes on your VirtualBox Host machine
Inside the Vagrant Box, on Powershell cd into c:\springboot
and run:
docker-compose scale weatherbackend=3
cd into weatherclient and run
java -jar target/weatherclient-0.0.1-SNAPSHOT.jar
Inside the Vagrant Windows Box: Open 2 Powershells and connect to the logs:
docker logs springboot_weatherservice_1 --follow
docker logs springboot_weatherbackend_1 --follow
On your Computer:
Go to localhost:8087/swagger-ui.html and do a GET on /forecast/{zip}
cd into step4-windows-linux-multimachine-vagrant-docker-swarm-setup and run
vagrant up
ansible-playbook -i hostsfile prepare-docker-nodes.yml
ansible-playbook -i hostsfile initialize-docker-swarm.yml
Have a look into Portainer UI on your Vagrant host:
cd into step5-deploy-multiple-spring-boot-apps-to-mixed-os-docker-swarm and run
ansible-playbook -i hostsfile build-and-deploy-apps-2-swarm.yml
Now have a look into the Traefik UI:
http://localhost:48080/dashboard/
All the services should be available through Docker Swarm routing mesh / ingress networking - on your Vagrant host:
weatherbackend: http://localhost:8090/swagger-ui.html
weatherservice: http://localhost:8095/soap
Eureka: http://localhost:8761/
Spring Boot Admin: http://localhost:8092/