Skip to content

pruneops_kubernetes_cluster (Resource)

A Kubernetes cluster whose in-cluster agent pushes workload metrics to PruneOps. Install the agent with the cluster id and agent_token (e.g. with a helm_release of the PruneOps agent chart). Registered clusters count towards the plan's account quota.

Example Usage

resource "pruneops_kubernetes_cluster" "prod" {
  name           = "prod-eu"
  provider_label = "eks"
  # Bump to revoke the agent token and issue a new one.
  token_version = 1
}

# The agent, installed with the cluster's id and token.
resource "helm_release" "pruneops_agent" {
  name             = "pruneops-k8s-agent"
  repository       = "oci://registry-1.docker.io/pruneops"
  chart            = "k8s-agent-chart"
  namespace        = "pruneops"
  create_namespace = true

  set           = [{ name = "pruneops.clusterId", value = pruneops_kubernetes_cluster.prod.id }]
  set_sensitive = [{ name = "pruneops.token", value = pruneops_kubernetes_cluster.prod.agent_token }]
}

Schema

Required

  • name (String) Display name, e.g. prod-eu.

Optional

  • collect_inventory (Boolean) Also collect Secrets (metadata only), ServiceAccounts, Namespaces and RoleBindings for the security audit. The agent needs the matching chart value (collectInventory=true).
  • ksm_url (String) kube-state-metrics URL, only when it is not at the agent chart's default.
  • provider_label (String) Where the cluster runs (eks, gke, aks, bare-metal…): labels the cluster and its costs.
  • token_version (Number) Change it to revoke the agent token and issue a new one (the agent must then be updated).

Read-Only

  • agent_token (String, Sensitive) The agent's token, issued on create and on token_version changes. Sensitive, kept in the Terraform state (it is generated by PruneOps): use an encrypted state backend. Null after an import: change token_version to get one.
  • id (String) Cluster id, generated by PruneOps (the agent's clusterId).

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

# agent_token cannot be read back: after the import, the first apply issues
# a new one if token_version is set.
terraform import pruneops_kubernetes_cluster.prod 4264852879a34d029404bf4599dd32da