Slide 1

Slide 1 text

Drone CI/CD Container-Native Continuous Delivery Platform https://github.com/drone/drone 2019/04/20

Slide 2

Slide 2 text

Bo-yi Wu (appleboy) Software Engineer in Mediatek https://blog.wu-boy.com https://github.com/appleboy appleboy appleboy46

Slide 3

Slide 3 text

Drone cloud free for the open source community https://cloud.drone.io/

Slide 4

Slide 4 text

--- kind: pipeline name: default steps: - name: backend image: golang commands: - go build - go test - name: frontend image: node commands: - npm install - npm test

Slide 5

Slide 5 text

https://github.com/drone/drone-ui

Slide 6

Slide 6 text

Drone 1.0 Features

Slide 7

Slide 7 text

Support Platform

Slide 8

Slide 8 text

Multi-Machine Multi-Architecture Multi-Cloud

Slide 9

Slide 9 text

--- kind: pipeline platform: arch: arm os: linux steps: - name: build image: golang commands: - go build - go test Linux amd64, Linux arm, Linux arm64 and Windows server

Slide 10

Slide 10 text

--- kind: pipeline name: backend platform: arch: arm os: linux steps: - name: build image: golang commands: - go build - go test --- kind: pipeline name: frontend platform: arch: amd64 os: linux steps: - name: build image: node commands: - npm install - npm test depends_on: - backend

Slide 11

Slide 11 text

--- kind: pipeline name: default steps: - name: backend image: golang commands: - go build - go test - name: frontend image: golang commands: - npm install - npm test - name: build image: plugins/slack settings: channel: general depends_on: - backend - frontend Faster Pipelines with Parallelization

Slide 12

Slide 12 text

local pipeline = import 'pipeline.libsonnet'; local name = 'drone-ssh'; [ pipeline.test, pipeline.build(name, 'linux', 'amd64'), pipeline.build(name, 'linux', 'arm64'), pipeline.build(name, 'linux', 'arm'), pipeline.release, pipeline.notifications(depends_on=[ 'linux-amd64', 'linux-arm64', 'linux-arm', 'release-binary', ]), ] Complex Configurations Simplified

Slide 13

Slide 13 text

Secret Management

Slide 14

Slide 14 text

--- kind: secret name: slack_webhook get: path: secret/data/slack name: webhook --- kind: pipeline name: default steps: - name: build image: golang commands: - go build - go test - name: notify image: plugins/slack settings: channel: general webhook: from_secret: slack_webhook

Slide 15

Slide 15 text

per-organization secrets http://bit.ly/drone-org-secrets

Slide 16

Slide 16 text

Cron Scheduling @hourly, @dailys, @weekly and @monthly

Slide 17

Slide 17 text

# example when configuration when: cron: [ nightly ] # example trigger configuration trigger: cron: [ nightly ]

Slide 18

Slide 18 text

Gitlab Pipelines image: ruby:2.2 services: - postgres:9.3 before_script: - bundle install test: script: - bundle exec rake spec --- kind: pipeline name: test platform: os: linux arch: amd64 steps: - name: test image: ruby:2.2 commands: - bundle install - bundle exec rake spec services: - name: postgres-9-3 image: postgres:9.3 ... $ drone convert .gitlab-ci.yml

Slide 19

Slide 19 text

automatic runtime conversion

Slide 20

Slide 20 text

Gitlab cache cache: untracked: true key: "$CI_BUILD_REF_NAME" paths: - node_modules/ stages: - setup - test setup: stage: setup script: - npm install test: stage: test script: - npm test --- kind: pipeline name: setup platform: os: linux arch: amd64 steps: - name: setup commands: - npm install - name: test commands: - npm test depends_on: - setup ...

Slide 21

Slide 21 text

Bitbucket Pipelines pipelines: default: - step: name: Build and test image: node:8.5.0 script: - npm install - npm test - npm build definitions: services: postgres: image: postgres:9.6.4 --- kind: pipeline name: default platform: os: linux arch: amd64 steps: - name: Build and test image: node:8.5.0 commands: - npm install - npm test - npm build services: - name: postgres image: postgres:9.6.4 ... $ drone convert bitbucket-pipelines.yml

Slide 22

Slide 22 text

automatic runtime conversion

Slide 23

Slide 23 text

Bitbucket cache pipelines: default: - step: caches: - node script: - npm install - npm test kind: pipeline name: default steps: - name: restore image: plugins/s3-cache settings: restore: true mount: - node_modules - name: build image: node commands: - npm install - npm test - name: rebuild image: plugins/s3-cache settings: rebuild: true mount: - node_modules

Slide 24

Slide 24 text

Autoscale in Drone https://autoscale.drone.io/

Slide 25

Slide 25 text

Agent Server Agent Agent Agent autoscaler https://github.com/drone/autoscaler

Slide 26

Slide 26 text

Task - Agent drone_server=server:9000 Task - Server port: 80/9000 ECS - Fargate ECS - Service Target Group Port: 80 Route 53 Service Discovery ALB / SSL Cloud Watch https://github.com/appleboy/drone-terraform-in-aws

Slide 27

Slide 27 text

Drone CI Infrastructure

Slide 28

Slide 28 text

Drone CI Infrastructure Agent Server Step 1 git clone Step 2 make build Step 3 deploy app work space extra service Agent

Slide 29

Slide 29 text

Drone Server • Support SSL • Custom SSL • Let’s Encrypt • Database • SQLite • MySQL • Postgres • S3 Storage: Store Large Text Files (build logs) • Log to stderr in joss-format by default

Slide 30

Slide 30 text

Drone + Prometheus

Slide 31

Slide 31 text

global: scrape_interval: 60s scrape_configs: - job_name: 'drone' bearer_token: your_token static_configs: - targets: ['domain.com']

Slide 32

Slide 32 text

Drone Agent • Linux amd64 • Linux arm • Linux arm64 • Windows 1803 • Windows 1809

Slide 33

Slide 33 text

route builds to specific agents CPU, Memory, GPUS

Slide 34

Slide 34 text

kind: pipeline name: default steps: - name: build image: golang commands: - go build - go test node: instance: highmem

Slide 35

Slide 35 text

Drone Plugin Any language you want

Slide 36

Slide 36 text

#!/bin/sh curl -X POST \ -H 'Content-type: application/json' \ -d '{"text":"hello"}' \ https://hooks.slack.com/services/...

Slide 37

Slide 37 text

#!/bin/sh curl -X POST \ -H 'Content-type: application/json' \ -d '{"text":"${PLUGIN_TEXT}"}' \ ${PLUGIN_WEBHOOK}

Slide 38

Slide 38 text

kind: pipeline name: default steps: - name: webhook image: janecitizen/slack settings: webhook: https://hooks.slack.com/... text: hello

Slide 39

Slide 39 text

http://plugins.drone.io

Slide 40

Slide 40 text

http://bit.ly/drone-2019