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

Drone.io in CI/CD World by Eugene Starchenko

Drone.io in CI/CD World by Eugene Starchenko

Amazon Web Services User Group Meetup
Modern trends in CI/CD
Containerization & Mircoservices
Continuous Deployments with Drone.io & AWS
#drone #ci #cd #aws

Avatar for Eugene Starchenko

Eugene Starchenko

March 01, 2018
Tweet

Other Decks in Technology

Transcript

  1. MODERN CI/CD SERVICE • GitHub/Bitbucket/GitLab integration • Support for many

    popular languages • Deployments (AWS, GCE, Azure, Heroku etc) • Build configuration stored in the repository • Builds executed in virtual machines • Output streamed live • Pipeline as a code • CLI support • Plugins • Notifications (Email, Slack, HipChat, etc)
  2. Why, Jenkins, WHY?! • Maintenance!? (over 50+ Jenkins boxes…) •

    High system resource usage (java in docker) • Broken dependencies / plugin version compatibility • Complicated project settings • Groovy?!
  3. It is open source under an Apache 2 license and

    can be installed on your own infrastructure for free. https://github.com/drone/drone DRONE.IO is a Continuous Delivery platform built on Docker, written in Go.
  4. DRONE PROS • The service is nice and simple. Easy

    to setup & maintain! • Lightweight CI/CD open source system written in Go (low resources usage) • Multi tenant system • Scales and grows with your team (drone agents) • Source control driven configuration (YAML) • Build on Docker for full customization (Isolated builds) • Access granted via Github Oauth and scoped to repo perms automatically • No more managing multiple jenkins (use docker modules) • Plugins can be written in any language that can read env vars • Support database engines (MySQL/Postgres/SQLite) • Cross compatible with Jenkins or any other Docker based CI service
  5. DRONE CONS • The single DB used for storing data

    on build logs etc. could be a single point of failure unless accounted for feature • The lack of features compared to Jenkins • Settings are too simple, with no way to customize (no permissions configuration) • No crons?! ( http://readme.drone.io/questions/how-to- schedule-builds ) • Limitations like "This feature is only available in the Enterprise Edition" or "Coming Soon”
  6. INSTALLATION • Single binary, just execute (with only a single

    OS dependency -- Docker) • Docker image (preferred way). Runs on ECS cluster as a service • Configuration through environment variables • Scale with build agents (poll the central drone server for jobs) • Can use RDS PostgresSQL as an alternate storage (default storage engine is an embedded SQLite database which requires zero installation or configuration.)
  7. CONCEPTS • Plugins • Pipeline • Services • Matrix •

    Secrets • Volumes • Drone CLI • Constraints • API
  8. CONCEPTS - Plugins • Plugin is actually just a Docker

    image • Container created and executed as part of pipeline • Exit code determines success or failure http://plugins.drone.io https://github.com/drone-plugins
  9. CONCEPTS - Pipeline • List of steps to build, test

    and deploy your code • Success determinates by exit code • Defined in repo root dir as .drone.yml • Drone retrieves the .drone.yml file for your commit / branch. If you make a change to the .drone.yml in a branch it does not impact master. • Parallel step execution (group) • Local build testing & debugging with drone cli\ • Skip builds by [ci skip] [skip ci] in commit
  10. #### #DRONE example - Build and Deploy Lambda Functions |

    Complete Lambda project’s pipeline #### pipeline: build: image: python:2.7-alpine commands: - apk update && apk add zip - pip install -r requirements.txt -t . - zip -r -9 lambda-project-${DRONE_BUILD_NUMBER}.zip * s3-publish: image: plugins/s3 acl: private region: us-east-1 bucket: some-bucket target: lambda-dir source: lambda-project-${DRONE_BUILD_NUMBER}.zip
  11. #### #DRONE example - Build and Deploy Lambda Functions |

    Complete Lambda project’s pipeline #### deploy-lambda: image: omerxx/drone-lambda-plugin pull: true function_name: my-function s3_bucket: some-bucket file_name: lambda-dir/revenue-report-${DRONE_BUILD_NUMBER}.zip notify-slack-releases: image: plugins/slack channel: product-releases webhook: https://hooks.slack.com/services/ABCD/XYZ username: Drone-CI
  12. CONCEPTS - Services • Set of services needed in build

    process (databases, ip server) • Available on the same network namespace as build containers • Services are accessed using custom hostnames • Handy for DB`s used in testing
  13. CONCEPTS - Matrix • Build and test a single commit

    against multiple configurations • Variables are interpolated in the yaml using the ${VARIABLE} syntax, before the yaml is parsed • Drone executes a separate build task for each combination in the matrix
  14. CONCEPTS - Secrets • Keep your secrets out of VCS

    (credstash, aws ssm parameter-store) • Injected into build containers as vars or plain text =) • Secrets can be added to the Drone secret store through CLI or UI (drone secret add \ ) • Limit to specific container or all images, repository in your pipeline • Available in the env. Mount a .env file into to container at /.env and drone would read parameters from this file. • Secrets in parameter expressions should be escaped (echo $${SECRET})
  15. CONCEPTS - Constraints • Pipeline Conditions (branch name, prefix/* ,

    build status, github events, environment) • Step Conditions: limit steps build status or by Events: tag, push, pull_request, deployment • Execute a step using custom include and exclude logic • Platform:[linux/*, windows/amd64] • Limit execution of build steps by instances • String Substitution (build metadata, ${DRONE_BRANCH/\//-}) • EnvVariables Reference (DRONE_COMMIT_SHA, etc.) • Run different pipeline steps from the cli than from repository hooks
  16. DO NOT BE SEDUCED BY THE TECHNOLOGY! A curates list

    of awesome Drone resources https://github.com/drone/awesome-drone https://github.com/drone-demos https://habrahabr.ru/post/324588/ https://www.2d1o.ru/episodes/s02e02.html https://github.com/go-training/drone-tutorial THANK YOU!