This repository manages Harness resources using the Harness Terraform Provider.
Here's the directory tree structure of this repository:
.
├── README.md
├── connectors.tf
├── definitions
│ ├── infrastructures_definition.yaml
│ ├── pipeline_definition.yaml
│ ├── service_definition.yaml
│ └── trigger_definition.yaml
├── environments.tf
├── infrastructures.tf
├── locals.tf
├── organization.tf
├── pipelines.tf
├── projects.tf
├── providers.tf
├── secrets.tf
├── services.tf
├── terraform.tfstate
└── triggers.tf
The pipeline architecture utilizes the following components:
- Artifact Registry
- GitHub Packages
- Source Repository
- GitHub
- Kubernetes Cluster
- GKE (Google Kubernetes Engine)
- CD Pipeline
- Harness (Next Gen)
The constructed pipeline configuration follows the prototype steps outlined below:
- Push a Docker image to GitHub Packages.
- Use Terraform to configure resources on Harness.
- Pushing changes to the specified branch in GitHub triggers the pipeline.
- An approval phase is initiated on Harness, requiring manual approval.
- Upon approval, the pipeline executes and deploys to GKE.
To get started with creating Harness resources using Terraform, follow the guide here.
- Terraform Installation
- Version: ~> 1.5.0
- Kubernetes Cluster Setup
- GKE
Authenticate using a personal access token (classic) with the following permissions:
- admin:repo_hook
- write:packages
- delete:packages
- repo
- user
Edit the following variables in locals.tf
and YAML files in the definitions
folder according to your environment.
# providers.tf
<version_number>
<your_harness_account_id>
<your_harness_pat>
# projects.tf
<your_project_identifier>
<your_project_name>
# connectors.tf
<your_connector_id>
<your_connector_name>
<your_github_repo_url>
# secrets.tf
<your_github_username>
<your_github_token_id>
<your_github_token_name>
<your_github_token_value>
# pipelines.tf
<your_pipelines_name>
<your_pipelines_id>
# services.tf
<your_service_name>
<your_service_id>
<your_service_manifest_id>
<your_service_connector_brach>
<your_service_artifact_registry>
<your_service_artifact_org>
# environments.tf
<your_environment_name>
<your_environment_id>
# infrastructures.tf
<your_infrastructure_name>
<your_infrastructure_id>
<your_cluster_name>
<your_cluster_namespace>
<your_cluster_releasename>
# triggers.tf
<your_trigger_name>
<your_trigger_id>
terraform login # Execute only once
terraform init
terraform plan
terraform apply
There are two ways to achieve this:
- Modify the harness_pipeline resource in
pipelines.tf
. - Use the GUI to modify the pipeline, fetch the YAML, and then update the harness_pipeline resource in
pipelines.tf
.