Continuous Delivery: Basic Concepts and the GitOps Revolution
What Is Continuous Delivery?
Continuous delivery (CD) is an application development practice that involves automatically preparing code changes for release to a production environment. Combined with continuous integration (CI), continuous delivery is a key aspect of modern software development. Together, these two practices are known as CI/CD.
Properly implemented CI enables developers to deploy any code change to testing and production environments late in the software development lifecycle (SDLC). Developers can thus rely on build artifacts that have passed standardized test processes and are ready for deployment.
With continuous delivery, developers can automate various tests (not just unit testing) to verify multiple aspects of software updates before releasing them to the customer. Automated tests might include API testing, load testing, functional and UI testing, integration testing, and so on. These tests help developers assess updates more thoroughly and identify issues before deploying a release to production.
In a cloud-based deployment, developers can easily and cost-effectively create and replicate multiple testing environments. When working on premises, dynamically creating test environments was traditionally more difficult. Kubernetes is helping organizations effectively automate CI/CD processes across clusters of nodes, both in on-premise data centers and in the public cloud.
What’s the Difference Between Continuous Delivery and Continuous Deployment?
Continuous delivery and continuous deployment are closely related concepts, indicating two levels of automation in a software development strategy.
Continuous delivery emphasizes automation that minimizes the manual effort required to deploy code changes. In a continuous delivery pipeline, developers create their code, it passes automated tests, and is then automatically integrated with a repository like a container registry or a binary repository. The operations teams can then deploy the code to the live production environment at the push of a button.
Continuous deployment emphasizes reducing the burden on operations teams to accelerate the application delivery process, expanding continuous delivery automation into the next SDLC stage. It typically includes automation of additional steps in releasing new software to minimize the manual processes required. For example, a continuous deployment pipeline may automatically release the development team’s changes from the repository to the production environment, where customers can use it. Continuous deployment is harder to achieve than Continuous Delivery as it automatically sends approved artifacts to production environments without any manual intervention.
What Is the Continuous Delivery Pipeline?
The continuous delivery pipeline has five primary phases:
Develop—a developer writes code with new or updated software functionality.
Commit—the developer commits the code to a version control system.
Stage—the change is deployed to a realistic environment for final testing.
Deploy—the change is deployed to a production environment.
What Automated Tests Are Run as Part of a CD Pipeline?
A critical part of the pipeline is the automated tests it can run to validate that software changes are ready for production. These tests include:
Unit tests—analyze code changes or individual software components
Smoke tests—a smoke test can identify problems that prevent the code from running at all.
System or integration testing—identifying that after the change, the software interacts correctly with other integrated systems. This can include white box and black box testing.
Acceptance testing—also known as user acceptance testing (UAT), this tests if the change meets user requirements, both in terms of functionality and non-functional requirements like performance and security.
Compatibility testing—identifying if the new version of the software can run on all required environments, such as different operating systems or browsers.
Load testing – checking how the system performs under different load conditions
Deploying to Production
The main identifying criterion of a true CD pipeline is that software can be deployed throughout its entire lifecycle. Any change to the software can be deployed to a testing or staging environment at the click of a button. Development teams receive fast feedback from automated tests, staging environments, and production environments, and can use this feedback to drive additional improvements.
What Are the Benefits of Continuous Delivery for Agile Development?
Continuous delivery has several advantages over traditional waterfall-style development:
Simpler releases—development teams spend less time preparing codebases for release and don’t combine multiple changes into a large, complex release. Instead, developers update and release code in small increments—ideally, every time they make a change.
Easier maintenance—minor releases quickly reveal bugs in new code. When software is frequently deployed to production, it is easy to identify production issues, isolate a recent change that caused the issue, fix it, test and redeploy.
Improved development velocity—in a continuous delivery environment, developers can iterate on software rapidly and deliver value to customers faster. New features can be accessed by customers much more quickly, and when customers have new requirements, development teams can rapidly respond to them.
Improved quality—continuous delivery makes releases more predictable, more reliable, and of higher quality. CD does not prevent bugs, but can catch them earlier in the development lifecycle and reduce their impact on customers.
Less downtime – removal of manual steps minimized the amount of human errors
Continuous Delivery Tools
Implementing continuous delivery requires setting up an extensive set of tools. The following tools are some of the basic components required for a continuous delivery pipeline.
Automated testing is essential for DevOps, agile, and CI/CD development practices. Various software tools can automate tests and enable a repeatable testing process with reusable tests. Test automation helps eliminate the manual burden of performing repetitive tasks and saves time.
Automated tests can run around the cloud and often produce more reliable results than manual tests, especially when it comes to repetitive tasks. Automation allows multiple tests to run simultaneously and can support large-scale testing. While it does take time to create automated tests, the upfront investment saves significant time later on and enables frequent software updates.
Automated tests can save time, but they do not replace skilled testers, who often collaborate with developers to write and prioritize automated tests.
Infrastructure as Code
Infrastructure as Code (IaC) lets DevOps teams extend computing, storage, and network infrastructure with version control, agile, or continuous delivery methods. IaC tools can help apply CI/CD mechanisms to build server images, configure test servers, and mix environments.
Developers and operators can use various IaC tools to automate infrastructure customization and control, eliminating the need to configure servers or operating systems manually. Software engineers often require IaC tools to handle the increasingly rapid application delivery cycles and release frequent updates.
IaC automation tools can support best practices and may be necessary to keep the infrastructure building process competitive. They enable effective infrastructure configuration and reduce the cost and effort of provisioning infrastructure.
Container orchestration tools automate container deployment, networking, scaling, and management. Orchestration is useful for any environment that uses containers, facilitating the deployment of an application across multiple environments. It also enables container lifecycle management to support DevOps teams using a CI/CD workflow.
Container orchestration platforms offer a framework for managing large-scale container architectures. Commonly used orchestrators include Kubernetes, OpenShift, Nomad, and Docker Swarm.
Orchestrators allow developers to distribute applications accross a number of different machines. Each application is managed with a set of configuration files.These configuration files enable the orchestrator to pull container images, establish a network access path, and store logs in a specified location.
Container management tools can automatically schedule the deployment of new containers to appropriate clusters and find a host based on the restriction and requirements specified in the configuration policy .
Merely setting up the CI/CD pipeline is not enough for a successful deployment. It is important to maintain observability over CI/CD processes with continuous monitoring to collect and analyze various metrics.
While continuous delivery enables rapid releases, it can also create additional challenges, given the pace of change. It requires careful examination and control over the entire software delivery process to mitigate the risks associated with frequent updates.
Monitoring and alerting tools can help DevOps teams keep track of all processes with features such as:
Vulnerability scanning—identifies critical faults introduced in the code, which may impact performance or security. It is also important to determine how quickly vulnerabilities are identified and fixed.
Long-term trend analysis—for example, the number of builds run per day compared to previous months. This trend may indicate a need to adjust the scale of the infrastructure.
Performance analysis—for example, whether the deployment is slower or faster than in previous weeks.
Alerts—inform teams of issues that require immediate attention, such as broken or vulnerable components, failed tests, and required rollbacks.
Forensic analysis—includes retrospective analysis of performance or security-related events, tying these to other, potentially related events.
GitOps Tools: Enabling Next-Generation CD
GitOps is a DevOps framework that applies software development best practices to infrastructure and deployment automation. GitOps enables the creation of automated workflows to implement application changes based on edits pushed to the Git repository. GitOps tools support continuous delivery by comparing an application’s current production state to the desired state defined in Git and automatically ensuring they match.
GitOps tools help incorporate DevOps practices such as version control, collaboration, and CI/CD into the deployment pipeline. DevOps teams can use these tools to automate application deployments and make their tasks easier. For example, developers can use familiar code repositories.
What is GitOps and Why is it Revolutionizing Continuous Delivery?
GitOps is a way to achieve continuous delivery of cloud-native applications. It provides a developer-centric experience, enabling development teams to work with tools they are already familiar with, and use them to drive complex environments.
The core idea of GitOps is to have a Git repository that contains a declarative configuration of the infrastructure and applications required for a production environment. Developers only need to state, via the declarative configuration, what needs to run in the environment, and an automated process deploys the necessary resources to match this configuration.
In a GitOps process, to deploy a new application or make changes to the environment, developers update their declarative configuration and commit it to the Git repository. Automated processes take care of everything after that point. The opposite is also true—GitOps agents monitor live environments and make corrections when they go out of sync with the desired configuration.
The GitOps process can be summarized as follows:
All configurations are stored in source control.
To make a configuration change, a developer issues a pull request.
The pull request is approved and merged into the production branch.
Automated systems, typically a GitOps agent, ensures that the production environment is fully synchronized with the new configuration.
Three important points about a GitOps development environment:
No human should make any configuration changes directly to the live environment. All changes are made through the source control system.
Operations teams are, in general, not involved. Developers make changes to environments in a self-service model via changes to declarative configuration.
It is critical to establish bidirectional synchronization between the GitOps repository and the live environment. Any change to one should be recognized and synchronized with the other.
The primary way to put GitOps into practice is pull-based deployment. In a traditional CI/CD pipeline, new code pushed to the application repository triggers deployment—in other words, it relies on an external event to trigger an action. By contrast, the pull-based method updates the application by frequently comparing the actual state of live infrastructure to the desired state specified in the environment repository. In Kubernetes, this is achieved by a GitOps controller that detects a discrepancy between the actual and desired states. Upon any discrepancy, it updates the infrastructure to match the environment repository. It might also check the image registry for new image versions to deploy.
Pull based deployment can thus reverse any change to the infrastructure that is not documented in the environment repository, maintaining the traceability of all changes in the Git log and preventing direct cluster changes that may cause state deviations.
Continuous Delivery with Codefresh
Delivering new software is the single most important function of businesses trying to compete today. Many companies get stuck with flaky scripting, manual interventions, complex processes, and large unreliable tool stacks across diverse infrastructure. Software teams are left scrambling to understand their software supply chain and discover the root cause of failures. It’s time for a new approach.
Codefresh helps you meet the continuous delivery challenge. Codefresh is a complete software supply chain to build, test, deliver, and manage software with integrations so teams can pick best-of-breed tools to support that supply chain.
Built on Argo, the world’s most popular and fastest-growing open source software delivery toolchain, Codefresh unlocks the full enterprise potential of Argo Workflows, Argo CD, Argo Events, and Argo Rollouts and provides a control-plane for managing them at scale.
Conquer DevOps with Codefresh
Realize your true DevOps potential with the premier GitOps solution powered by Argo.