Overview
The process below defines how to provision Harness connectors to get K8s costs into CCM.
Permissions
You will need access to create CCM connectors in Harness.
Setup Providers
We need to leverage the Harness Terraform provider. We will use this provider to create two connectors for each cluster. We will also define all of our cluster names within Terraform locals
block. The cluster names will be used to create the connectors.
terraform {
required_providers {
harness = {
source = "harness/harness"
}
}
}
provider "harness" {}
locals {
cluster_names = toset(["cluster-a", "cluster-b", "cluster-c"])
}
Create A K8s Connector For Each Cluster
This is the first connector we need to provision. It addresses the question: "How do I connect to the delegate in the cluster"?
resource "harness_platform_connector_kubernetes" "cluster-connector" {
for_each = local.cluster_names
identifier = replace(each.value, "-", "_")
name = replace(each.value, "_", "-")
inherit_from_delegate {
delegate_selectors = [each.value]
}
}