This project automates the GitOps workflow steps of the Harness Guestbook app CD tutorial using Terraform. The Tf module:
- Provisions the GitOps agent in Harness
- Installs the agent in a local Kubernetes cluster
- Creates Harness repo, cluster, environment, and service resources
- Deploys and syncronizes the guestbook application to the cluster.
- Clone this repo to a machine that has Terraform command line tools installed, and can connect to a local K8 cluster.
- Change into gitops-terraform-onboarding/ and run
terraform init
. - Open terraform.tfvars. This file is pre-filled with demo values for the Harness resources. Leave them as they are or change to reflect your environment.
- Set your Harness credentials. Run
export TF_VAR_harness_api_token=<your Harness access token>
.
NOTE Be sure not to add your PAT to .tfvars! - Set your Harness account info. Run
export TF_VAR_account_id=<your Harness account ID>
. Your account ID can be found in the web URL when accessing the Harness app. - Run
terraform plan
. Terraform should output that 9 resoures will be created. - Run
terraform apply
and confirm when prompted. Terraform will provision the Harness GitOps agent, install the agent in the cluster, create other Harness resources, and deploy the guestbook application. - Run
kubectl get pods
and verify the guestbook application was deployed. - Run
kubectl port-forward svc/guestbook-ui 8080:80
and verify the guestbook application opens as expected.
- Run
terraform destroy
from the gitops-terraform-onboarding/ directory. Confirm when prompted. - Run
kubectl get pods
to confirm the Harness resources were deleted.