Slide 1

Slide 1 text

Kai Tödter

Slide 2

Slide 2 text

Who am I?  Principal Key Expert at Siemens Building Technologies  Web Technology Fan  Open Source Lover  E-mail: [email protected]  Twitter: twitter.com/kaitoedter  Blog: toedter.com/blog 4/10/2018 2 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License.

Slide 3

Slide 3 text

Show Hands! 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 3

Slide 4

Slide 4 text

Outline  Build Pipeline with Docker  Setting up  Jenkins  SonarQube  Artifactory  Terraform  AWS Deployment 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 4

Slide 5

Slide 5 text

Demo (Local Docker)  https://192.168.99.100 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 5

Slide 6

Slide 6 text

How to run the Demo?  Install Docker  git clone https://github.com/toedter/cd-pipeline  cd docker  Edit the docker host in cd-pipeline.sh or .bat  When using Windows: Make sure *.sh files and plugins.txt have Unix line endings  Run cd-pipeline.sh or .bat 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 6

Slide 7

Slide 7 text

DevOps CAMS  Culture  Automation  Measurement  Sharing 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 7

Slide 8

Slide 8 text

4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 8 Automation

Slide 9

Slide 9 text

What can be automated  Testing  Build Pipelines  Build Infrastructure  Deployments  Monitoring  Configuration  … 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 9

Slide 10

Slide 10 text

Infrastructure as Code  Automation of infrastructure creation  Servers, OS, software, storage, networking, …  Stored in code repositories  Lots of tools available  SaltStack, Puppet, Chef, Terraform, Ansible, …  Infrastructure as Code is the approach “treating infrastructure like software” 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 10

Slide 11

Slide 11 text

Creating a Build Pipeline  Jenkins  Continuous Integration  SonarQube  Internal Quality  Artifactory  Binary Artifact Repository 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 11

Slide 12

Slide 12 text

4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 12

Slide 13

Slide 13 text

Docker  Docker images for  Jenkins, Sonarqube, Artifactory, nginx  Extra container for tools configuration  Docker Compose  for defining and running the multi-container pipeline tools 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 13

Slide 14

Slide 14 text

Dockerfile (nginx) FROM nginx COPY nginx-selfsigned.crt /etc/ssl/ COPY nginx-selfsigned.key /etc/ssl/ COPY index.html /usr/share/nginx/html/ COPY *.png /usr/share/nginx/html/ COPY nginx.conf /etc/nginx 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 14

Slide 15

Slide 15 text

Docker Compose version: '3.2' networks: cd-tools-network: driver: bridge services: sonarqubedb: image: postgres container_name: sonarqube-db environment: - POSTGRES_USER=sonar - POSTGRES_PASSWORD=sonar volumes: - /volumes/postgres/data:/var/lib/postgresql/data 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 15

Slide 16

Slide 16 text

Docker Code Deep Dive 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 16

Slide 17

Slide 17 text

Pipeline as Code  Jenkins => Jenkinsfile  TracisCI => .travis.yml  Gitlab CI => .gitlab-ci.yml 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 17

Slide 18

Slide 18 text

Jenkinsfile pipeline { agent { docker { image 'java:openjdk-8' args '--network=docker_cd-tools-network' } } stages { stage('build + tests') { steps { sh './gradlew test' } } … 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 18

Slide 19

Slide 19 text

4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 19 Terraform

Slide 20

Slide 20 text

Terraform  Write  Infrastructure as code  Plan  Preview changes before applying  Create  Always reproducible infrastructure 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 20

Slide 21

Slide 21 text

Pipeline, Terraform and AWS  Create Security Groups  Configure SSH keys  Create EC2 instance  Provide scripts that are executed after creation  Output IP address 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 21

Slide 22

Slide 22 text

Terraform Code Deep Dive 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 22

Slide 23

Slide 23 text

Demo (AWS)  https:// 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 23

Slide 24

Slide 24 text

What’ Next?  DNS entries for all tools  Let’s Encrypt Certificates  Backup/Restore  Monitoring with Prometheus and Grafana  Support of Nexus and Teamscale  AWS Spot instances  Single & Multi host deployments 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 24

Slide 25

Slide 25 text

NextGen Pipeline Demo (AWS) 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 25

Slide 26

Slide 26 text

4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 26 Discussion

Slide 27

Slide 27 text

Links  Github Repo: https://github.com/toedter/cd-pipeline  Terraform: https://www.terraform.io/ 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 27

Slide 28

Slide 28 text

License  This work is licensed under a Creative Commons Attribution 4.0 International License.  See http://creativecommons.org/licenses/by/4.0/ 4/10/2018 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 28