> 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/harness-ai/use-harness-platform/connectors/cloud-providers/add-a-rancher-cluster-connector.md).

# Add a Rancher cluster connector

Connect Harness to Kubernetes clusters managed by Rancher.

Use a Harness Rancher cluster connector to connect Harness to Kubernetes clusters managed by Rancher. Use the Rancher cluster connector to deploy to Rancher-managed on-prem Kubernetes clusters from Harness pipelines.

***

## What you will learn from this topic

* How to [create a Rancher cluster connector](#create-a-rancher-cluster-connector) using the Harness Manager.
* How to define a Rancher cluster connector using a [YAML example](#yaml-example).

***

## Before you begin

* **Rancher server URL**: The URL of your Rancher server, for example `https://rancher.mycompany.com`. Go to [Create an API key](https://ranchermanager.docs.rancher.com/reference-guides/user-settings/api-keys) in the Rancher documentation. The **Endpoint** value shown when you create an API key is your Rancher server URL.
* **Rancher API bearer token**: A Rancher API bearer token for a dedicated service account or user, stored as a Harness secret. Go to [Create an API key](https://ranchermanager.docs.rancher.com/reference-guides/user-settings/api-keys) in the Rancher documentation to generate one from **Account & API Keys** in the Rancher UI. Rancher displays the bearer token only once, so copy and store it immediately.
* **Target cluster and namespace names**: The names of the Rancher-managed clusters and namespaces you want Harness to deploy to.
* **Harness Delegate**: A running Harness Delegate that can reach your Rancher server. Go to [Delegate installation overview](/harness-ai/use-harness-platform/delegates/delegate/install-delegates/overview.md) to install one. The Rancher cluster connector always communicates with Rancher through a Harness Delegate.

If you do not administer the Rancher server yourself, request the following from your Rancher administrator:

* The Rancher URL.
* The target cluster names and namespace names.
* A Rancher API bearer token for a dedicated service account or user.
* Confirmation of whether the token is scoped to specific clusters.

### Minimum permissions <a href="#minimum-permissions" id="minimum-permissions"></a>

The Rancher bearer token must allow the APIs Harness uses, including:

* `/v3/clusters`
* `/v3/clusters/{clusterName}?action=generateKubeconfig`

The underlying Rancher user typically needs one of the following:

* **Cluster Owner** on the target cluster.
* A **Global Permission** set that enables cluster administration.

### Network requirements <a href="#network-requirements" id="network-requirements"></a>

* Outbound HTTPS from the Harness Delegate to the Rancher endpoint.
* If your Rancher server uses an internal certificate authority (CA), the delegate must trust the Rancher CA chain.

***

## Create a Rancher cluster connector <a href="#create-a-rancher-cluster-connector" id="create-a-rancher-cluster-connector"></a>

Perform the following steps to create the Rancher cluster connector using the Harness Manager. The connector wizard has four steps: **Overview**, **Details**, **Delegates Setup**, and **Connection Test**.

1. Open a Harness project, and select **Connectors** under **Project Setup**. You can also create connectors at the account or organization levels.
2. Select **New Connector**, and then select **Rancher Cluster** under **Cloud Providers**.

### Overview <a href="#overview" id="overview"></a>

Enter a **Name** for the connector. **Description** and **Tags** are optional. Harness automatically creates an **Id** ([entity identifier](/harness-ai/use-harness-platform/references/entity-identifier-reference.md)) for the connector based on the **Name**. Select **Continue** to proceed to **Details**.

![Overview step of the Rancher cluster connector wizard](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-b2a6a161aa61402803977d12bed440ba778c6239%2Francher-connector-overview.png?alt=media)

### Details <a href="#details" id="details"></a>

Select **Specify rancher URL and credentials**, and then select **Continue** after entering the following details:

* **Rancher URL**: Enter your Rancher server URL, for example `https://rancher.mycompany.com`.
* **Authentication**: Select **Bearer Token**.
* **Token**: Select **Create or Select a Secret** to add your Rancher API bearer token.

![Details step of the Rancher cluster connector wizard](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-17ca9278132f2d83519226b47b001dab034a2941%2Francher-connector-details.png?alt=media)

### Delegates Setup <a href="#delegates-setup" id="delegates-setup"></a>

Select one of the following options, and then select **Save and Continue**:

* **Use any available Delegate**.
* **Only use Delegates with all of the following tags**: Enter the tag of the [delegate](#before-you-begin) you installed.

![Delegates Setup step of the Rancher cluster connector wizard](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-7489e628742451d5e57132bf94e00b86533933e7%2Francher-connector-delegatesetup.png?alt=media)

### Connection Test <a href="#connection-test" id="connection-test"></a>

Harness validates the Rancher cluster connector authentication and permissions. Once verification succeeds, select **Finish**.

![Connection Test step of the Rancher cluster connector wizard](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-2db4aa614e77a0fdf4df5586674d37f7713a1742%2Francher-connector-connectiontest.png?alt=media)

The connector now appears in the **Connectors** list.

***

## YAML example <a href="#yaml-example" id="yaml-example"></a>

The following YAML defines a Rancher cluster connector that authenticates using a bearer token.

<details>

<summary>Rancher cluster connector YAML</summary>

```yaml
connector:
  name: Rancher-Connector # Connector display name shown in the Harness UI
  identifier: RancherConnector # Unique connector identifier, cannot be changed after creation
  description: "" # Optional description for the connector
  accountIdentifier: <YOUR_ACCOUNT_ID> # Harness account identifier that owns the connector
  orgIdentifier: default # Harness org identifier that owns the connector
  projectIdentifier: <YOUR_PROJECT_ID> # Harness project identifier that owns the connector
  type: Rancher
  spec:
    ignoreTestConnection: false # Set to true to skip the connection test when the connector is saved
    credential:
      type: ManualConfig
      spec:
        rancherUrl: https://rancher.mycompany.com # Rancher server URL
        auth:
          type: BearerToken
          spec:
            passwordRef: account.<YOUR_RANCHER_TOKEN_SECRET_REF> # Harness secret reference storing your Rancher API bearer token
```

</details>

***

## Next steps

* [Delegate installation overview](/harness-ai/use-harness-platform/delegates/delegate/install-delegates/overview.md): Install and configure a Harness Delegate for your Rancher cluster connector.

{% @harness-feedback/feedback module="harness-ai" pagePath="harness-ai/use-harness-platform/connectors/cloud-providers/add-a-rancher-cluster-connector" %}
