Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Drone 1.0 Feature

Bo-Yi Wu
April 22, 2019

Drone 1.0 Feature

This talk will describe all of the reasons for drone CI/CD 1.0, all of its features demonstrate its functionality, I will cover the background of Drone, how we built it, why we built it.

Bo-Yi Wu

April 22, 2019
Tweet

More Decks by Bo-Yi Wu

Other Decks in Technology

Transcript

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  6. Drone 1.0 Features

    View Slide

  7. Support Platform

    View Slide

  8. Multi-Machine
    Multi-Architecture
    Multi-Cloud

    View Slide

  9. ---
    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

    View Slide

  10. ---
    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

    View Slide

  11. ---
    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

    View Slide

  12. 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

    View Slide

  13. Secret Management

    View Slide

  14. ---
    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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  18. 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

    View Slide

  19. automatic runtime conversion

    View Slide

  20. 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
    ...

    View Slide

  21. 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

    View Slide

  22. automatic runtime conversion

    View Slide

  23. 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

    View Slide

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

    View Slide

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

    View Slide

  26. 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

    View Slide

  27. Drone CI
    Infrastructure

    View Slide

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

    View Slide

  29. 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

    View Slide

  30. Drone + Prometheus

    View Slide

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

    View Slide

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

    View Slide

  33. route builds to
    specific agents
    CPU, Memory, GPUS

    View Slide

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

    View Slide

  35. Drone Plugin
    Any language you want

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  39. http://plugins.drone.io

    View Slide

  40. http://bit.ly/drone-2019

    View Slide