Learning DevOps

Book description

Simplify your DevOps roles with DevOps tools and techniques

Key Features

  • Learn to utilize business resources effectively to increase productivity and collaboration
  • Leverage the ultimate open source DevOps tools to achieve continuous integration and continuous delivery (CI/CD)
  • Ensure faster time-to-market by reducing overall lead time and deployment downtime

Book Description

The implementation of DevOps processes requires the efficient use of various tools, and the choice of these tools is crucial for the sustainability of projects and collaboration between development (Dev) and operations (Ops). This book presents the different patterns and tools that you can use to provision and configure an infrastructure in the cloud. You'll begin by understanding DevOps culture, the application of DevOps in cloud infrastructure, provisioning with Terraform, configuration with Ansible, and image building with Packer. You'll then be taken through source code versioning with Git and the construction of a DevOps CI/CD pipeline using Jenkins, GitLab CI, and Azure Pipelines. This DevOps handbook will also guide you in containerizing and deploying your applications with Docker and Kubernetes. You'll learn how to reduce deployment downtime with blue-green deployment and the feature flags technique, and study DevOps practices for open source projects. Finally, you'll grasp some best practices for reducing the overall application lead time to ensure faster time to market.

By the end of this book, you'll have built a solid foundation in DevOps, and developed the skills necessary to enhance a traditional software delivery process using modern software delivery tools and techniques

What you will learn

  • Become well versed with DevOps culture and its practices
  • Use Terraform and Packer for cloud infrastructure provisioning
  • Implement Ansible for infrastructure configuration
  • Use basic Git commands and understand the Git flow process
  • Build a DevOps pipeline with Jenkins, Azure Pipelines, and GitLab CI
  • Containerize your applications with Docker and Kubernetes
  • Check application quality with SonarQube and Postman
  • Protect DevOps processes and applications using DevSecOps tools

Who this book is for

If you are a developer or a system administrator interested in understanding continuous integration, continuous delivery, and containerization with DevOps tools and techniques, this book is for you.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Learning DevOps
  3. Dedication
  4. Foreword
  5. About Packt
    1. Why subscribe?
  6. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  7. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Code in Action
      4. Conventions used
    4. Get in touch
      1. Reviews
  8. Section 1: DevOps and Infrastructure as Code
  9. DevOps Culture and Practices
    1. Getting started with DevOps
    2. Implementing CI/CD and continuous deployment
      1. Continuous integration (CI)
        1. Implementing CI
      2. Continuous delivery (CD)
      3. Continuous deployment
    3. Understanding IaC practices
      1. The benefits of IaC
      2. IaC languages and tools
        1. Scripting types
        2. Declarative types
      3. The IaC topology
        1. The deployment and provisioning of the infrastructure
        2. Server configuration
        3. Immutable infrastructure with containers
        4. Configuration and deployment in Kubernetes
      4. IaC best practices
    4. Summary
    5. Questions
    6. Further reading
  10. Provisioning Cloud Infrastructure with Terraform
    1. Technical requirements
    2. Installing Terraform
      1. Manual installation
      2. Installation by script
        1. Installing Terraform by script on Linux
        2. Installing Terraform by script on Windows
        3. Installing Terraform by script on macOS
      3. Integrating Terraform with Azure Cloud Shell
    3. Configuring Terraform for Azure
      1. Creating the Azure SP
      2. Configuring the Terraform provider
        1. Terraform configuration for local development and testing
    4. Writing a Terraform script to deploy Azure infrastructure
      1. Following some Terraform good practices
        1. Better visibility with the separation of files
        2. Protection of sensitive data
        3. Dynamizing the code with variables and interpolation functions
    5. Deploying the infrastructure with Terraform
      1. Initialization
      2. Previewing changes
      3. Applying the changes
    6. Terraform command lines and life cycle
      1. Using destroy to better rebuild
      2. Formatting and validating the code
        1. Formatting the code
        2. Validating the code
      3. Terraform's life cycle in a CI/CD process
    7. Protecting tfstate in a remote backend
    8. Summary
    9. Questions
    10. Further reading
  11. Using Ansible for Configuring IaaS Infrastructure
    1. Technical requirements
    2. Installing Ansible
      1. Installing Ansible with a script
      2. Integrating Ansible into Azure Cloud Shell
      3. Ansible artifacts
      4. Configuring Ansible
    3. Creating an inventory for targeting Ansible hosts
      1. The inventory file
      2. Configuring hosts in the inventory
      3. Testing the inventory
    4. Writing the first playbook
      1. Writing a basic playbook
      2. Understanding Ansible modules
      3. Improving your playbooks with roles
    5. Executing Ansible
      1. Using the preview or dry run option
      2. Increasing the log level output
    6. Protecting data with Ansible Vault
      1. Using variables in Ansible for better configuration
      2. Protecting sensitive data with Ansible Vault
    7. Using a dynamic inventory for Azure infrastructure
    8. Summary
    9. Questions
    10. Further reading
  12. Optimizing Infrastructure Deployment with Packer
    1. Technical requirements
    2. An overview of Packer
      1. Installing Packer
        1. Installing manually
        2. Installing by script
          1. Installing Packer by script on Linux
          2. Installing Packer by script on Windows
          3. Installing Packer by script on macOS
          4. Integrating Packer with Azure Cloud Shell
          5. Checking the Packer installation
    3. Creating Packer templates for Azure VMs with scripts
      1. The structure of the Packer template
        1. The builders section
        2. The provisioners section
        3. The variables section
      2. Building an Azure image with the Packer template
    4. Using Ansible in a Packer template
      1. Writing the Ansible playbook
      2. Integrating an Ansible playbook in a Packer template
    5. Executing Packer
      1. Configuring Packer to authenticate to Azure
      2. Checking the validity of the Packer template
      3. Running Packer to generate our VM image
    6. Using a Packer image with Terraform
    7. Summary
    8. Questions
    9. Further reading
  13. Section 2: DevOps CI/CD Pipeline
  14. Managing Your Source Code with Git
    1. Technical requirements
    2. Overviewing Git and its command lines
      1. Git installation
      2. Configuration Git
      3. Git vocabulary
      4. Git command lines
        1. Retrieving a remote repository
        2. Initializing a local repository
        3. Configuring a local repository
        4. Adding a file for the next commit
        5. Creating a commit
        6. Updating the remote repository
        7. Synchronizing the local repository from the remote
        8. Managing branches
    3. Understanding the Git process and GitFlow pattern
      1. Starting with the Git process
        1. Creating and configuring a Git repository
        2. Committing the code
        3. Archiving on the remote repository
        4. Cloning the repository
        5. The code update
        6. Retrieving updates
      2. Isolating your code with branches
      3. Branching strategy with GitFlow
        1. The GitFlow pattern
        2. GitFlow tools
    4. Summary
    5. Questions
    6. Further reading
  15. Continuous Integration and Continuous Delivery
    1. Technical requirements
    2. The CI/CD principles
      1. Continuous integration (CI)
      2. Continuous delivery (CD)
    3. Using a package manager
      1. Private NuGet and npm repository
      2. Nexus Repository OSS
      3. Azure Artifacts
    4. Using Jenkins
      1. Installing and configuring Jenkins
      2. Configuring a GitHub webhook
      3. Configuring a Jenkins CI job
      4. Executing the Jenkins job
    5. Using Azure Pipelines
      1. Versioning of the code with Git in Azure Repos
      2. Creating the CI pipeline
      3. Creating the CD pipeline: the release
    6. Using GitLab CI
      1. Authentication at GitLab
      2. Creating a new project and managing your code source
      3. Creating the CI pipeline
      4. Accessing the CI pipeline execution details
    7. Summary
    8. Questions
    9. Further reading
  16. Section 3: Containerized Applications with Docker and Kubernetes
  17. Containerizing Your Application with Docker
    1. Technical requirements
    2. Installing Docker
      1. Registering on Docker Hub
      2. Docker installation
      3. An overview of Docker's elements
    3. Creating a Dockerfile
      1. Writing a Dockerfile
      2. Dockerfile instructions overview
    4. Building and running a container on a local machine
      1. Building a Docker image
      2. Instantiating a new container of an image
      3. Testing a container locally
    5. Pushing an image to Docker Hub
    6. Deploying a container to ACI with a CI/CD pipeline
      1. The Terraform code for ACI
      2. Creating a CI/CD pipeline for the container
    7. Summary
    8. Questions
    9. Further reading
  18. Managing Containers Effectively with Kubernetes
    1. Technical requirements
    2. Installing Kubernetes
      1. Kubernetes architecture overview
      2. Installing Kubernetes on a local machine
      3. Installing the Kubernetes dashboard
    3. First example of Kubernetes application deployment
    4. Using HELM as a package manager
    5. Using AKS
      1. Creating an AKS service
      2. Configuring kubectl for AKS
      3. Advantages of AKS
    6. Creating a CI/CD pipeline for Kubernetes with Azure Pipelines
      1. The build and push of the image in the Docker Hub
      2. Automatic deployment of the application in Kubernetes
    7. Summary
    8. Questions
    9. Further reading
  19. Section 4: Testing Your Application
  20. Testing APIs with Postman
    1. Technical requirements
    2. Creating a Postman collection with requests
      1. Installation of Postman
      2. Creating a collection
      3. Creating our first request
    3. Using environments and variables to dynamize requests
    4. Writing Postman tests
    5. Executing Postman request tests locally
    6. Understanding the Newman concept
    7. Preparing Postman collections for Newman
      1. Exporting the collection
      2. Exporting the environments
    8. Running the Newman command line
    9. Integration of Newman in the CI/CD pipeline process
      1. Build and release configuration
        1. Npm install
        2. Npm run newman
        3. Publish test results
      2. The pipeline execution
    10. Summary
    11. Questions
    12. Further reading
  21. Static Code Analysis with SonarQube
    1. Technical requirements
    2. Exploring SonarQube
    3. Installing SonarQube
      1. Overview of the SonarQube architecture
      2. Installing SonarQube
        1. Manual installation of SonarQube
        2. Installation via Docker
        3. Installation in Azure
    4. Real-time analysis with SonarLint
    5. Executing SonarQube in continuous integration
      1. Configuring SonarQube
      2. Creating a CI pipeline for SonarQube in Azure Pipelines
    6. Summary
    7. Questions
    8. Further reading
  22. Security and Performance Tests
    1. Technical requirements
    2. Applying web security and penetration testing with ZAP
      1. Using ZAP for security testing
      2. Ways to automate the execution of ZAP
    3. Running performance tests with Postman
    4. Summary
    5. Questions
    6. Further reading
  23. Section 5: Taking DevOps Further
  24. Security in the DevOps Process with DevSecOps
    1. Technical requirements
    2. Testing Azure infrastructure compliance with Chef InSpec
      1. Overview of InSpec
      2. Installing InSpec
      3. Configuring Azure for InSpec
      4. Writing InSpec tests
        1. Creating an InSpec profile file
        2. Writing compliance InSpec tests
      5. Executing InSpec
    3. Using the Secure DevOps Kit for Azure
      1. Installing the Azure DevOps Security Kit
      2. Checking the Azure security using AzSK
      3. Integrating AzSK in Azure Pipelines
    4. Preserving data with HashiCorp's Vault
      1. Installing Vault locally
      2. Starting the Vault server
      3. Writing secrets in Vault
      4. Reading secrets in Vault
      5. Using the Vault UI web interface
      6. Getting Vault secrets in Terraform
    5. Summary
    6. Questions
    7. Further reading
  25. Reducing Deployment Downtime
    1. Technical requirements
    2. Reducing deployment downtime with Terraform
    3. Understanding blue-green deployment concepts and patterns
      1. Using blue-green deployment to improve the production environment
      2. Understanding the canary release pattern
      3. Exploring the dark launch pattern
    4. Applying blue-green deployments on Azure
      1. Using App Service with slots
      2. Using Azure Traffic Manager
    5. Introducing feature flags
    6. Using an open source framework for feature flags
    7. Using the LaunchDarkly solution
    8. Summary
    9. Questions
    10. Further reading
  26. DevOps for Open Source Projects
    1. Technical requirements
    2. Storing the source code in GitHub
      1. Creating a new repository on GitHub
      2. Contributing to the GitHub project
    3. Contributing using pull requests
    4. Managing the changelog and release notes
    5. Sharing binaries in GitHub releases
    6. Using Travis CI for continuous integration
    7. Getting started with GitHub Actions
    8. Analyzing code with SonarCloud
    9. Detecting security vulnerabilities with WhiteSource Bolt
    10. Summary
    11. Questions
    12. Further reading
  27. DevOps Best Practices
    1. Automating everything
    2. Choosing the right tool
    3. Writing all your configuration in code
    4. Designing the system architecture
    5. Building a good CI/CD pipeline
    6. Integrating tests
    7. Applying security with DevSecOps
    8. Monitoring your system
    9. Evolving project management
    10. Summary
    11. Questions
    12. Further reading
  28. Assessments
    1. Chapter 1: DevOps Culture and Practices
    2. Chapter 2: Provisioning Cloud Infrastructure with Terraform
    3. Chapter 3: Using Ansible for Configuring IaaS Infrastructure
    4. Chapter 4: Optimizing Infrastructure Deployment with Packer
    5. Chapter 5: Managing Your Source Code with Git
    6. Chapter 6: Continuous Integration and Continuous Delivery
    7. Chapter 7: Containerizing Your Application with Docker
    8. Chapter 8: Managing Containers Effectively with Kubernetes
    9. Chapter 9: Testing APIs with Postman
    10. Chapter 10: Static Code Analysis with SonarQube
    11. Chapter 11: Security and Performance Tests
    12. Chapter 12: Security in the DevOps Process with DevSecOps
    13. Chapter 13: Reducing Deployment Downtime
    14. Chapter 14: DevOps for Open Source Projects
    15. Chapter 15: DevOps Best Practices
  29. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Learning DevOps
  • Author(s): Mikael Krief
  • Release date: October 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781838642730