> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-continuous-delivery/cd-building-blocks/environments/cluster-view-overview.md).

# Cluster view

See live Kubernetes resources, cluster health, and deployment history for a cluster directly in Harness

Harness lets you deploy to Kubernetes clusters, and cluster view shows you what is actually running in them. Without cluster view, checking resource health or troubleshooting a cluster requires leaving Harness for an external tool such as Lens or K9s. When you enable cluster discovery on an infrastructure definition, Harness deploys a lightweight collector agent to your cluster and shows the resources it finds, their health, and the deployments that targeted them, directly on the environment and infrastructure definition pages.

Cluster view is supported on the following Kubernetes infrastructure types: Kubernetes (Direct), Google Kubernetes Engine (GKE), Amazon Elastic Kubernetes Service (EKS), and Azure Kubernetes Service (AKS). Other types, such as Rancher, are not supported.

***

## What you will learn from this topic

* How to [enable cluster discovery](#enable-cluster-discovery) on an infrastructure definition.
* Understand [what cluster view shows](#what-you-see-in-cluster-view) on the environment and infrastructure definition **K8s Resources** tabs.
* Understand which [resource types](#supported-resource-types) cluster view discovers and displays.
* Understand what the [discovery statuses](#discovery-statuses) mean and when they appear.

***

## Before you begin

Complete the following requirements before you enable cluster discovery:

* **A Kubernetes infrastructure definition**: Cluster view is available on static Kubernetes infrastructure definitions. Go to [Kubernetes infrastructure](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/define-your-kubernetes-target-infrastructure.md) to create one if you do not already have one.
* **A fixed namespace**: The infrastructure definition's namespace field must be a fixed value. Infrastructure definitions that use a runtime input or expression for the namespace are not supported.
* **A working Kubernetes connector**: The collector agent connects to your cluster through the delegate associated with your Kubernetes connector. By default, Harness provisions the agent's service account and RBAC automatically; no separate setup is required. Go to [Kubernetes cluster connector settings reference](https://developer.harness.io/docs/platform/connectors/cloud-providers/ref-cloud-providers/kubernetes-cluster-connector-settings-reference) to review connector roles and policies, or go to [Install the cluster discovery Helm chart](/continuous-delivery/use-continuous-delivery/cd-building-blocks/environments/install-the-cluster-discovery-helm-chart.md) if your cluster policy requires a pre-provisioned service account instead.
* **Environment permissions**: View and Create/Edit on the environment and its infrastructure definitions. Go to the [permissions reference](https://developer.harness.io/docs/platform/role-based-access-control/permissions-reference) to review the required permissions.

***

## Enable cluster discovery

When you enable cluster discovery, Harness deploys a lightweight collector agent to your cluster, built on the same Kubernetes service discovery agent technology as a scoped-down version of the Harness Chaos Engineering agent.

Perform the following steps to enable cluster discovery:

1. Create or edit a Kubernetes infrastructure definition.
2. Scroll down to the **Cluster Details** section.
3. Select **Enable Cluster Discovery**.
4. Set the **Service Account** field based on your cluster policy:
   * **Leave it empty** if your Kubernetes connector has permission to create a service account. Harness provisions one automatically and uses it to deploy the collector agent.
   * **Enter a service account name** if your cluster policy does not allow Harness to create a service account. Go to [Install the cluster discovery Helm chart](/continuous-delivery/use-continuous-delivery/cd-building-blocks/environments/install-the-cluster-discovery-helm-chart.md) to create a scoped-down service account yourself, using the Helm chart Harness publishes at [github.com/harness/helm-cd-cluster-view](https://github.com/harness/helm-cd-cluster-view), then enter that service account's name here. The Helm chart only creates the service account and its RBAC; it does not install the collector agent. Harness still deploys and connects the agent itself, through the delegate associated with your Kubernetes connector.

![Enable Cluster Discovery checkbox and optional Service Account field on the infrastructure definition form](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-85318862029aff2d7be9a93a2ac3220fc470ffff%2Fcluster-view-enable-discovery-field.png?alt=media)

{% hint style="info" %}
**Enable Cluster Discovery**

Harness needs read-only access to list and watch deployments, replica sets, daemon sets, stateful sets, pods, services, nodes, namespaces, jobs, and cron jobs. No action needed if your connector has permission to create a service account; Harness uses it to provision one automatically. To manage the service account yourself instead, install the Helm chart and enter its name below.
{% endhint %}

***

## What you see in cluster view

### Environment-level view

On an environment's **K8s Resources** tab, Harness lists every Kubernetes cluster connected to that environment through its infrastructure definitions, along with:

* The number of infrastructure definitions associated with the cluster.
* The number of namespaces associated with the cluster.
* The cluster's discovery status.

![Environment K8s Resources tab listing a connected cluster with its infrastructure definition count, namespace count, and discovery status](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-3122152821f73fa2dd1d241aa1088b7456ee654a%2Fcluster-view-environment-cluster-list.png?alt=media)

### Infrastructure definition-level view

On an infrastructure definition's **K8s Resources** tab, Harness shows three sub-tabs, scoped to that infrastructure definition's cluster and namespace.

{% tabs %}
{% tab title="Resources" %}
The **Resources** sub-tab shows a count card for each resource type cluster view discovers, for example **Replica Sets 511** or **Nodes 7**. Select a card to filter the table below it to that resource type.

![Resource type count cards on the Resources sub-tab](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-7ef34c73477dbdad68d74d858df853affccd5c7b%2Fcluster-view-resource-type-cards.png?alt=media)

The table lists individual resources with the following columns:

* Name
* Namespace
* Ready
* Up-to-date
* Available
* Age
* Health

Use **Add filter** to filter the table by **Health** or **Namespace**, or use the search box to find a resource by name.

![Resources table with the Add filter dropdown open, showing Health and Namespace filter options](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-72f5840094c37c126e431336d6ce204de6bb533a%2Fcluster-view-resources-filters.png?alt=media)

Select a resource to view its details and the YAML manifest Harness discovered for it. Harness shows a **Last synced** timestamp above the table, next to a manual refresh control.
{% endtab %}

{% tab title="Infra Definitions" %}
The **Infra Definitions** sub-tab lists the infrastructure definitions associated with this cluster, with the following columns:

* Name
* Infrastructure Type
* Namespaces
* Discovery Status

Harness deploys one collector agent per cluster. If you enable cluster discovery for a second infrastructure definition that points at a cluster Harness already discovers, Harness reuses the existing agent instead of deploying a new one.

![Infra Definitions sub-tab listing the infrastructure definition associated with the cluster, its type, namespace, and discovery status](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-f7578ac2ef13eec2199991d128e5a4e0982b96ff%2Fcluster-view-infra-definitions-tab.png?alt=media)
{% endtab %}

{% tab title="Deployments" %}
The **Deployments** sub-tab lists the Harness pipeline executions that targeted this cluster, with the following columns:

* Execution
* Service
* Status
* Artifact
* Trigger
* Deployed time

Select an execution to go to its pipeline execution details.

![Deployments sub-tab listing pipeline executions that targeted the cluster](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-aef765f68fb737ee953e4e5673572cb1a4b4cd2c%2Fcluster-view-deployments-tab.png?alt=media)
{% endtab %}
{% endtabs %}

Cluster view shows every resource it discovers in the target namespace; it does not filter resources by service. Namespace-scoped resources, such as deployments, pods, and replica sets, refresh continuously through Kubernetes informers and watches. Cluster-scoped resources, such as nodes and namespaces themselves, refresh on a five-minute interval.

***

## Supported resource types

Cluster view syncs and displays the following resource types, in this order:

* Deployments
* Pods
* StatefulSets
* DaemonSets
* Jobs
* CronJobs
* ReplicaSets
* Replication Controllers
* Services
* Namespaces
* Nodes

Harness uses the delegate's existing read-only (`get`, `list`, `watch`) access to these resource types. Harness never creates, modifies, or deletes resources in your cluster through discovery.

***

## Discovery statuses

An infrastructure definition with cluster discovery enabled shows one of the following statuses:

* **In progress**: Harness is syncing resources for the first time. Hover over the status for details; this may take a few minutes.
* **Active**: Harness is syncing resources successfully.
* **Failed**: The last sync attempt failed. Hover over the status to see the specific error.

***

## Next steps

You can enable cluster discovery on an infrastructure definition and review the Kubernetes resources, health, and deployment history for its target cluster from the environment and infrastructure definition **K8s Resources** tabs.

* [Environments overview](/continuous-delivery/use-continuous-delivery/cd-building-blocks/environments/environment-overview.md): Review how infrastructure definitions fit into an environment.

{% @harness-feedback/feedback %}
