CI/CD Introduction
What is CI/CD?
CI: Continuous integration (CI) is the practice of automating the integration of code changes from multiple contributors into a single software project. It’s a primary DevOps best practice, allowing developers to frequently merge code changes into a central repository where builds and tests then run. Automated tools are used to assert the new code’s correctness before integration. (source)
CD: Continuous deployment is a strategy for software releases wherein any code commit that passes the automated testing phase is automatically released into the production environment, making changes that are visible to the software's users. (source)
CI/CD in the Cloud
If your target is have your application in the cloud, then you will need to create your infrastructure first, and then have your code deployed.
One way to achieve this, is to manually create your infra in the cloud by, for example, going to the management console of your cloud provider and create resources manually (e.g. compute instances, databases, object storage, etc.). This traditional approach has various disadvantages:
- It’s difficult and time-consuming to repeat
- It’s difficult to roll-back in case of problems
- It has no validation or testing phase
- It has no history of previous changes
- It has no inherent documentation
Plus, as it’s done manually, it’s not possible to incorporate it in a CI/CD pipeline.
Infrastructure as Code
The idea behind infrastructure as code (IaC) is that you write and execute code to define, deploy, update, and destroy your infrastructure. This represents an important shift in mindset in which you treat all aspects of operations as software—even those aspects that represent hardware (e.g., setting up physical servers). In fact, a key insight of DevOps is that you can manage almost everything in code, including servers, databases, networks, log files, application configuration, documentation, automated tests, deployment processes, and so on.
The fact that infrastructure is defined in code makes it possible to be incorporated into a CI/CD pipeline and get all the benefits that it offers.
Popular IaC Tools
| Chef | Puppet | Ansible | Pulumi | CloudFormation | Heat | Terraform | |
|---|---|---|---|---|---|---|---|
| Source | Open | Open | Open | Open | Closed | Open | Open |
| Cloud | All | All | All | All | AWS | All | All |
| Type | Config Mgmt | Config Mgmt | Config Mgmt | Provisioning | Provisioning | Provisioning | Provisioning |
| Infra | Mutable | Mutable | Mutable | Immutable | Immutable | Immutable | Immutable |
| Paradigm | Procedural | Declarative | Procedural | Declarative | Declarative | Declarative | Declarative |
| Language | GPL | DSL | DSL | GPL | DSL | DSL | DSL |
| Master | Yes | Yes | No | No | No | No | No |
| Agent | Yes | Yes | No | No | No | No | No |
| Paid Service | Optional | Optional | Optional | Must-have | N/A | N/A | Optional |
| Community | Large | Large | Huge | Small | Small | Small | Huge |
| Maturity | High | High | Medium | Low | Medium | Low | Medium |