While designing the next iteration of Harness CD, our core focus was on making our complete pipelines developer-friendly. The creation of a complete Harness pipeline through YAML is one step towards that. In fact, we took a YAML-first approach. This blog will explain the process behind coming up with a simple CD YAML.
What Is a Pipeline?
A Pipeline is an end-to-end process that delivers a new version of your software. But Pipelines can be much more: Pipelines can be a cyclical process that includes integration, delivery, operations, testing, deployment, real-time changes, and monitoring.
What Are Organizations and Projects?
Harness Organizations (Orgs) allow you to group projects that share the same goal. For example, all projects for a business unit or division.
A Harness Project contains Harness Pipelines, users, and resources that share the same goal. For example, a Project could represent a business unit, division, or simply a development project for an app.
You can learn more about Harness key concepts and definitions in our documentation.
What Is a Stage?
A Stage is a subset of a Pipeline that contains the logic to perform one major segment of the Pipeline process. Stages are based on the different milestones of your Pipeline, such as building, approving, and delivering.
What Are Services and Service Definitions?
A Service represents your microservices, Serverless functions, and other workloads logically.
Service Definitions represent the real artifacts, manifests, and variables of a Service.
What Are Infrastructure, Infrastructure Definitions, and Environments?
Infrastructure tells you where to deploy the service. It contains Environment and Infrastructure Definition.
Environments represent your deployment targets logically (QA, Prod, etc).
Infrastructure Definitions represent your target infrastructure physically. They are the actual clusters, hosts, etc.
By separating Environments and Infrastructure Definitions, you can use the same Environment in multiple stages while changing the target infrastructure settings with each stage.
What Is Execution?
In the Execution section, a person can define Steps so as to tell how to deploy the service to the infrastructure provided.
What Is a Step?
A Step is an individual operation in a stage, like running a shell script or HTTP call.
What Are Connectors?
Connectors contain the information necessary to integrate and work with third party tools. For example, to connect with your GitHub account, etc.
After learning about terminologies, let’s write the YAML to deploy a publicly available manifest to Kubernetes.
In the YAML, we first define the pipeline metadata:
In the above YAML, we give the name and identifier to the pipeline element, the identifier being unique across all pipelines. Apart from it, a pipeline can exist under a project, which exists under an organization.
Then, we add a stage (Deploy) to perform deployment operation in the pipeline.
Now, think from a developer perspective: when you have to deploy something, what questions come to your mind?
Now, add Service to your YAML, which will define artifacts and manifests to be used for deployment. In service definition, we’ll use the publicly-available manifest from Kubernetes.
Here, we are defining a manifest containing the nginx YAML, where we are providing file path, repoName, and GitHub connector details.
You can learn more about creating connectors of different types in our documentation.
Next, we will add Infrastructure to the YAML, defining the Kubernetes cluster details using a connector, namespace, and releaseName.
At last, we will add the Execution section, where we will add the Kubernetes rolling deploy step. This is a standard Kubernetes rolling update.
Voila! The pipeline is completed, and now you can sit back and execute it.
Complete Pipeline YAML: https://gist.github.com/archit-harness/7d507d603775725c671300290d14e79c
Stay tuned for Part Two of this series, where we will tell you more about the other concepts : InputsSets, FailureStrategies, Conditional Execution, and more. In the meantime, if you’re interested in learning more about Harness, book your demo today.