Slide 1

Slide 1 text

Β© Engineering Yet another Continuous Delivery talk Giovanni Toraldo / Solution Developer Engineering D.HUB Incontro Devops 2021 #idi2021 CONTINUOUS DELIVERY

Slide 2

Slide 2 text

Β© Engineering About me Open source Remote-first software developer / devops Solution developer in Engineering D.HUB Often teleported into the 14th century πŸ›‘βš”πŸŽ― CONTINUOUS DELIVERY / BIO Giovanni Toraldo

Slide 3

Slide 3 text

Β© Engineering About Cloudesire Whitelabel marketplace SaaS billing Channel management IaaS, PaaS, SaaS catalog 2012 - R&D project 2013 - Cloudesire.com 2016 - Tim Venture seed 600K 2020 - Engineering acquisition CONTINUOUS DELIVERY / BIO

Slide 4

Slide 4 text

Β© Engineering Antipatterns are everywhere – Manual deployments are a waste of time – Infrequent deployments cause late feedback – Manual configuration of environments leads to configuration drift – Manual testing leads to regressions – Can we do better? CONTINUOUS DELIVERY / THEORY

Slide 5

Slide 5 text

Β© Engineering What Continuous Delivery can do – Short cycles – Reliability – Early feedback – Market pressure – Customer satisfaction CONTINUOUS DELIVERY / THEORY

Slide 6

Slide 6 text

Β© Engineering Continuous Delivery phases CONTINUOUS DELIVERY / THEORY

Slide 7

Slide 7 text

Β© Engineering How we do achieve our goal? CONTINUOUS DELIVERY / PRACTICES

Slide 8

Slide 8 text

Β© Engineering Backlog β€’ One place for high-level issues (epic, stories) β€’ Focus on describing the problem you want to solve, not solutions ● Developers knows what is good for you β€’ Prioritization as a contract with stakeholders β€’ Commit for a plan and try to stick with it (#noestimates) β€’ Current status should be transparent ● Feedback to non-developers when releases happens ● Meetings are ok but everyone happy and no meetings is better CONTINUOUS DELIVERY / PRACTICES

Slide 9

Slide 9 text

Β© Engineering Automated testing / TDD – Probably the most underrated practice for achieving velocity β€’ Writing tests is HARD for newcomers β€’ Maintaining test suites is HARD for everyone (e.g.: flappers) β€’ Still, it’s worth the time β€’ Optimize build times to avoid slow feedback β€’ Tests give hints on how a function should work CONTINUOUS DELIVERY / PRACTICES

Slide 10

Slide 10 text

Β© Engineering Continuous integration β€’ Treat it like your best friend, you can rely on it β€’ Ensure that you are not going to break everything in a single move β€’ Repetitive tasks belongs to here ● Compile code ● Execute regression tests ● Generate documentation ● Publish new artifacts CONTINUOUS DELIVERY / PRACTICES

Slide 11

Slide 11 text

Β© Engineering Code reviews β€’ Spot bugs before reaching users β€’ Share ownership and abandon blame culture β€’ Meet specifications β€’ Keep the bar high β€’ Written trail of design decisions β€’ Asynchronous feedback β€’ Mentor juniors without doing anything special CONTINUOUS DELIVERY / PRACTICES

Slide 12

Slide 12 text

Β© Engineering Packaging / Distribution β€’ A strict requirement for automated releases β€’ Every commit is a release candidate β€’ Standard packaging (e.g. Docker) β€’ Central artifacts repository (Nexus, Artifactory) ● Accessible from all the execution environments CONTINUOUS DELIVERY / PRACTICES

Slide 13

Slide 13 text

Β© Engineering Automated releases β€’ Every environment should be a prod-like environment ● Have at least a test environment for every prod environment β€’ Repeatable procedures reusable in every environment β€’ Rollback should be easy as a standard release β€’ Releases should be tracked somewhere (GIT, CI) β€’ Releases must not affects customers CONTINUOUS DELIVERY / PRACTICES

Slide 14

Slide 14 text

Β© Engineering Feedback loop β€’ Automatic deployment to one prod-like environment β€’ Release daily on staging environments β€’ Ask for explicit feedback after changes from tester/QA/stakeholders β€’ Meaningful and searchable application logs β€’ Proactively monitor exceptions and errors CONTINUOUS DELIVERY / PRACTICES

Slide 15

Slide 15 text

Β© Engineering Infrastructure as code β€’ Forgot SSH commands or clicking buttons β€’ Repeatable procedures β€’ Standardization β€’ Objects Inventory β€’ Document without actually writing documentation CONTINUOUS DELIVERY / PRACTICES

Slide 16

Slide 16 text

Β© Engineering Microservices architectures β€’ Maintaining a unique codebase has exponential difficulty ● Divide et impera β€’ Requires a trained release pipeline β€’ Avoid repeating yourself via: ● Boilerplate projects ● Shared libraries ● Automated updates ● DOCUMENTATION CONTINUOUS DELIVERY / PRACTICES

Slide 17

Slide 17 text

Β© Engineering What’s in our toolbox CONTINUOUS DELIVERY / TOOLING

Slide 18

Slide 18 text

Β© Engineering Github β€’ GIT repository hosting β€’ Lightweight issue management ● There is a label for everything ● Type: Bug, new feature, change feature, operations, devops ● Priority: P1, P2, P3, P4 ● Effort: light, medium, high, epic ● Workflow: in-progress, ready-for-staging, test, ready, awaiting-feedback, blocked ● Topic: UI/UX, billing, ERP... ● Customer ● Stalebot that warns and close inactive issue for more than 3 months β€’ Documentation as markdown files β€’ Planning via weekly milestones ● Internal dashboard to track milestones progress CONTINUOUS DELIVERY / TOOLING

Slide 19

Slide 19 text

Β© Engineering Internal dashboard for milestones tracking CONTINUOUS DELIVERY / TOOLING

Slide 20

Slide 20 text

Β© Engineering Dependabot β€’ Automatic dependencies updates for your repositories on Github β€’ PR get opened automatically with changelog between versions β€’ Triggered weekly by a schedule on early monday ● PR are already built and ready to be merged β€’ Security updates with links to CVEs β€’ Supports most dependency management tools and Dockerfile β€’ Enabled on all repositories via Terraform CONTINUOUS DELIVERY / TOOLING

Slide 21

Slide 21 text

Β© Engineering .github/dependabot.yml version: 2 registries: maven-internal-releases: type: maven-repository url: https://repo.cloudesire.com/repository/internal username: ${{secrets.MAVEN_USER}} password: ${{secrets.MAVEN_PASS}} updates: - package-ecosystem: maven directory: /cloudesire-root schedule: interval: weekly day: sunday registries: - maven-internal-releases assignees: - gionn - malteo - package-ecosystem: docker directory: /cloudesire-root/cmw schedule: interval: weekly day: sunday assignees: - gionn - malteo CONTINUOUS DELIVERY / TOOLING

Slide 22

Slide 22 text

Β© Engineering Dependabot automated pull request CONTINUOUS DELIVERY / TOOLING

Slide 23

Slide 23 text

Β© Engineering CircleCI β€’ Cloud CI services better than in-house: ● Scalability ● Predictable pricing β€’ Batteries included compared to Jenkins β€’ A bit of downsides: ● Not so configurable (e.g. tests parallelization) ● Can’t add new projects via API ● Docker integration slightly cumbersome since beginning β€’ Reuse pipeline configuration via ORB CONTINUOUS DELIVERY / TOOLING

Slide 24

Slide 24 text

Β© Engineering CircleCI ORB example CONTINUOUS DELIVERY / TOOLING

Slide 25

Slide 25 text

Β© Engineering CircleCI workflow diagram CONTINUOUS DELIVERY / TOOLING

Slide 26

Slide 26 text

Β© Engineering CircleCI job detail CONTINUOUS DELIVERY / TOOLING

Slide 27

Slide 27 text

Β© Engineering Sonar (static analysis) β€’ Catch bugs automatically β€’ Discovery and learn (why is this an issue?) β€’ Enforce standards (quality gates) β€’ Applied systematically for every project β€’ Reports integrated in PR (developer edition) β€’ Security audits (Hotspots) CONTINUOUS DELIVERY / TOOLING

Slide 28

Slide 28 text

Β© Engineering Terraform (Infrastructure as code) β€’ Supports many providers: ● Iaas: AWS, Azure, GCP, ... ● Saas: Cloudflare, Github, ... ● API: Vault, ... β€’ Follow common development workflow ● PR ● Code review ● CI pipelines CONTINUOUS DELIVERY / TOOLING

Slide 29

Slide 29 text

Β© Engineering Automated terraform plan on pull requests CONTINUOUS DELIVERY / TOOLING

Slide 30

Slide 30 text

Β© Engineering CircleCI workflow for terraform repository CONTINUOUS DELIVERY / TOOLING

Slide 31

Slide 31 text

Β© Engineering Chef (configuration management) β€’ Still the configuration management tool after 8+ yrs β€’ Provision new production environment in 30 minutes ● script to generate new chef environments β€’ Nightly integration tests on cloud infrastructure β€’ Provision can run from CI or developers box CONTINUOUS DELIVERY / TOOLING

Slide 32

Slide 32 text

Β© Engineering Graylog β€’ Centralized logs collection ● Applications via GELF ● Syslog ● Docker logs β€’ Elasticsearch monthly indexes ● configurable retention β€’ Full-text search on every field, cross-environment CONTINUOUS DELIVERY / TOOLING

Slide 33

Slide 33 text

Β© Engineering Sentry β€’ Push applications exceptions via API β€’ Aggregate similar exceptions β€’ Mark as Resolved ● Flagged as regression if found again β€’ Mark as Ignored for n time β€’ Searchable β€’ Slack integration ● Each component in a different channel ● Only for new errors, regressions or repeated errors in a timeframe CONTINUOUS DELIVERY / TOOLING

Slide 34

Slide 34 text

Β© Engineering Sentry issue example CONTINUOUS DELIVERY / TOOLING

Slide 35

Slide 35 text

Β© Engineering How to release CONTINUOUS DELIVERY / RELEASE

Slide 36

Slide 36 text

Β© Engineering Step 1: open a release PR on ops repo via Merger script β€’ Select which chef environment you want to update β€’ Iterate on all the platform components installed on the environment to: ● Retrieve the latest successful build of master branch on CircleCI ● Compare build number with currently installed docker image version ● CI deploy jobs tag docker images with build number ● If a new version is available, compare current and previous commit-id on Github ● Parse commits to search for PR and referenced github issues β€’ Open a pull request with version changes on chef environment ● Branch name is always `release-envName` ● PR body contains the changelog for every components and links to issue ● Issues are linked via a redirector domain to avoid references spam CONTINUOUS DELIVERY / RELEASE

Slide 37

Slide 37 text

Β© Engineering Example Release PR CONTINUOUS DELIVERY / TOOLING

Slide 38

Slide 38 text

Β© Engineering Step 2: PR review, approve, merge, provision β€’ Follows the standard development workflow (review, approve, merge) β€’ When building master, CI pipeline detect if the built commit is: ● A release PR generated by Merger ● A generic PR with a label `deploy/envName` β€’ Run Chef sequentially on all the nodes of the environment CONTINUOUS DELIVERY / RELEASE

Slide 39

Slide 39 text

Β© Engineering Step 3: profit β€’ If the release fails, the CI send an email to release owners and exceptions are pushed to sentry/slack β€’ If the release is successful: ● The release PR get labeled as `deployed` and a comment is left with the link of the build ● Every referenced issue in the release PR body receive a comment stating that a release is just happened ● If the referenced issue had a label: ● `workflow/ready-for-staging` is replaced by `workflow/test` ● `workflow/ready` the issue is closed CONTINUOUS DELIVERY / RELEASE

Slide 40

Slide 40 text

Β© Engineering Release schedule via CircleCI β€’ Release PR are automatically opened following a weekly schedule: ● Main staging environment every weekday until friday ● Main demo environment on friday, copying main staging versions ● Main production environment on monday, copying main demo versions ● Secondary (clients) staging environment on different day of the week, copying main production versions ● Secondary (clients) production environment on different days of the week, copying from their staging environment CONTINUOUS DELIVERY / RELEASE

Slide 41

Slide 41 text

Β© Engineering Wrap-up β€’ Continuous delivery is a game changer when developing products β€’ Try to continuously improve, one step at a time β€’ Automate all the things CONTINUOUS DELIVERY / SUMMARY

Slide 42

Slide 42 text

Β© Engineering www.eng.it Engineering Ingegneria Informatica SpA @EngineeringSpa gruppo.engineering LifeAtEngineering Thanks! Giovanni Toraldo @gionn