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

GitOps: Using Git as a deployment mechanism

GitOps: Using Git as a deployment mechanism

Git is used by a lot of developers to keep track of their changes and to collaborate on projects. While the source code is typically hosted on a central server (Github, Gitlab, etc...), this server is generally not used for more advanced workflows.

Because most of the tasks you perform on a repository are very descriptive, you can use them to trigger build and deployment events. Pushing code to the server could trigger a deploy to the testing server, pushing a tag to the server could trigger a deploy to production, and so on! If you use semantic versioning, you can even target more specific deployment servers.

Git is already part of your development workflow, start using it as part of your deployment workflow: GitOps.

Jachim Coudenys

November 14, 2017
Tweet

More Decks by Jachim Coudenys

Other Decks in Programming

Transcript

  1. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Other features Code

    Repository Tickets Merge Requests Wiki ... Running idle most of the time
  2. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e develop The main

    development branch Ideally this branch only contains merge commits
  3. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e master This branch

    represents code in production This branch must only contain merge commits
  4. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e feature/* New development

    is done in a feature branch This branch is started from develop and will be merged back into develop when it’s done By using a feature branch, you can leverage merge request
  5. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e release/* This branch

    sits between develop and master (getting ready for a new production release) This branch is short-lived and totally optional
  6. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e hotfix/* When something

    is wrong in production, a fix can be produced via a hotfix branch This branch is started from master and will be merged into both master and develop
  7. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e In software engineering,

    continuous integration (CI) is the practice of merging all developer working copies to a shared mainline several times a day. -- https://en.wikipedia.org/wiki/Continuous_integration
  8. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Extreme programming (XP)

    adopted the concept of CI and did advocate integrating more than once per day – perhaps as many as tens of times per day. -- https://en.wikipedia.org/wiki/Continuous_integration
  9. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Key Points 1.

    Commit Early, Commit Often 2. Never Commit Broken Code 3. Fix build failures immediately 4. Fail Fast 5. Act on metrics 6. Build in every target environment 7. Create artefacts from every build
  10. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Continuous delivery (CD)

    is a software engineering approach in which teams produce software in short cycles, ensuring that the software can be reliably released at any time. -- https://en.wikipedia.org/wiki/Continuous_delivery
  11. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e It aims at

    building, testing, and releasing software faster and more frequently. The approach helps reduce the cost, time, and risk of delivering changes by allowing for more incremental updates to applications in production. A straightforward and repeatable deployment process is important for continuous delivery. -- https://en.wikipedia.org/wiki/Continuous_delivery
  12. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Continuous Delivery ≠

    Continuous Deployment Continuous deployment: every change is automatically deployed to production. Continuous delivery: ensures every change can be deployed to production. In order to do continuous deployment one must be doing continuous delivery.
  13. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Git as the

    Source of Truth version control history peer review rollback
  14. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e SvnOps at my

    first job Mimic server filesystem in SVN Rsync new files to server Restart services (linked to file path)
  15. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e ChatOps, a term

    widely credited to GitHub, is all about conversation-driven development. By bringing your tools into your conversations and using a chat bot modified to work with key plugins and scripts, teams can automate tasks and collaborate, working better, cheaper and faster. -- https://www.pagerduty.com/blog/what-is-chatops/
  16. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e While in a

    chat room, team members type commands that the chat bot is configured to execute through custom scripts and plugins. These can range from code deployments to security event responses to team member notifications. The entire team collaborates in real-time as commands are executed. -- https://www.pagerduty.com/blog/what-is-chatops/
  17. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e GitOps in combination

    with ChatOps Git has better history Git(lab) has a more bundled view Report to chat, finale GO from chat ...
  18. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Semantic versioning is

    a way of applying versions to your software so it’s clear what impact it may have. https://blog.jachim.be/2017/07/git-flow-dtap-semver/
  19. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Given a version

    number MAJOR.MINOR.PATCH, increment the: MAJOR version when you make incompatible API changes, MINOR version when you add functionality in a backwards-compatible manner, and PATCH version when you make backwards-compatible bug fixes. Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
  20. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Merge develop in

    master: MAJOR.MINOR tag (only increment the MAJOR number is the change is big enough)
  21. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e DevOps toolchain Code

    — code development and review, source code management tools, code merging Build — continuous integration tools, build status Test — continuous testing tools that provide feedback on business risks Package — artifact repository, application pre-deployment staging Release — change management, release approvals, release automation Configure — infrastructure configuration and management, Infrastructure as Code tools Monitor — applications performance monitoring, end–user experience
  22. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Further reading How

    we're building GitLab into the complete DevOps toolchain. Beyond CI/CD: GitLab's DevOps vision Auto DevOps Auto DevOps brings DevOps best practices to your project by automatically configuring your build, test, code quality assurance, review apps, deployment, and monitoring in a single environment.
  23. Jachim Coudenys - - [email protected] @coudenysj https://joind.in/talk/d8b4e Summary Put everything

    it Git Don't do anything manually Put the server to work! Take a look at Gitlab CI/CD