# Registering Clusters

Clusters are registered automatically when a CMA Agent is deployed and started on the cluster. There is no manual registration step in the CMA Master UI.

## How It Works

CMA uses an **agent-based auto-discovery** model. When the CMA Agent starts on a cluster, it:

1. Connects to the local Cloudera Manager using the configured credentials
2. Discovers the cluster's services, hosts, and metadata
3. Establishes an outbound gRPC connection to the CMA Master
4. Registers the cluster with the Master, including all discovered metadata
5. The cluster automatically appears in the CMA Master UI as a source, ready for scanning

```mermaid
sequenceDiagram
    actor Admin
    participant CM as Cloudera Manager
    participant Agent as CMA Agent
    participant Master as CMA Master
    participant UI as CMA Web UI

    Admin->>CM: Deploy and configure CMA Agent service
    Admin->>CM: Start CMA Agent
    CM->>Agent: Agent process starts
    Agent->>CM: Query cluster metadata (services, hosts)
    CM-->>Agent: Cluster metadata
    Agent->>Master: gRPC: Connect + register cluster
    Master-->>Agent: Registration acknowledged
    Master->>UI: Cluster appears as source
```

## Prerequisites

Before deploying the CMA Agent on a source cluster:

- CMA parcel is distributed and activated on the cluster
- CMA Master is running and accessible from the source cluster network
- Cloudera Manager admin credentials are available

## Steps

1. In Cloudera Manager on the source cluster, select **Add Service** and choose **CMA_AGENT**.
2. Configure the required properties:

    | Property | Description |
    |----------|-------------|
    | `cma_master_service` | CMA Master service name — use when the Agent is on the **same** cluster as the Master (e.g., `CMA_MASTER`) |
    | `cma_master_url` | URL of the CMA Master gRPC endpoint — use when the Agent is on a **different** cluster (e.g., `http://master-host:8091`) |
    | `cm_username` | Cloudera Manager admin username |
    | `cm_password` | Cloudera Manager admin password |
    | `cma_user_home` | Home directory for the cma-agent user (e.g., `/home/cma-agent`) |

    > **Note:** Set either `cma_master_service` or `cma_master_url`, not both.

3. Start the CMA Agent service.
4. The agent connects to the Master and registers the cluster automatically.

## Result

The source cluster appears on the **Clusters** page in the CMA Master UI. You can review its details and services by clicking on the cluster name.

## After You Finish

Scan the data and workloads on the registered source cluster to discover the resources available for migration.
