# How to onboard a cluster

{% hint style="success" %}
PerfectScale is compatible and can be deployed in any Kubernetes environment, including EKS/EKS Anywhere, GKE, AKS, KOPS, private cloud, and other Kubernetes distributions.
{% endhint %}

## Onboarding instructions

1. Log in to the PerfectScale app using the ingress URL obtained [here](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/provisioner-installation#step-1-retrive-webapp-url).
2. Once logged in, navigate to the **`Overview`** tab.
3. You can see a button to connect a new Kubernetes cluster. To connect a new cluster, click the **`Add Cluster`** button. A pop-up window with the following steps will appear.<br>

   <figure><img src="https://content.gitbook.com/content/zCh9aABpk7yLeToPr6vk/blobs/vypSBJqhIkzjZq1PXP8K/Group%203084.png" alt="Onboard first cluster"><figcaption><p>Onboard first cluster</p></figcaption></figure>

{% hint style="info" %}
To provision clusters dynamically, follow the instructions for [Onboarding clusters programmatically](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/getting-started/onboarding-clusters-programmatically).
{% endhint %}

### Cluster configuration

<figure><img src="https://content.gitbook.com/content/zCh9aABpk7yLeToPr6vk/blobs/r4UxUPyRjFri2eh6200Z/image.png" alt="Cluster configuration" width="563"><figcaption><p>Cluster configuration</p></figcaption></figure>

{% hint style="info" %}
PerfectScale does not support Windows nodes. If your cluster contains both Windows and Linux nodes, adding the nodeSelector to run PerfectScale exporter on the Linux nodes is necessary. Follow the [**extra instructions**](#mix-of-windows-and-linux-nodes) provided to run PerfectScale on these nodes.
{% endhint %}

4. In a popup window, click **`Copy to Clipboard`** and clone the helm chart provided on p.1.
5. Enter a name for your cluster and select the desired [**Optimization Policy**](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/administration/cluster-settings#general-settings)**:**
   * MaxSavings - maximum cost savings, the best for non-production environments
   * Balanced (default) - optimally balances cost and resiliency
   * ExtraHeadroom - the best fit for latency-sensitive environments&#x20;
   * MaxHeadroom - keeps the environment above the highest spikes

{% hint style="info" %}
The **Optimization Policy** feature allows you to specify how your resources should be allocated in order to support the individual needs of your workloads. Define the policies that best suit your environment and business goals, depending on whether you want to maximize cost savings or provide extra headroom to maintain the resilience of mission-critical services.\
\
The **Optimization Policy** can be set for the entire [cluster](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/administration/cluster-settings#general-settings) and for a specific [workload](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/visibility-and-optimization/podfit-or-vertical-pod-right-sizing#workload-optimization-policy). The workload's **Optimization Policy** takes precedence and will override the value defined at the cluster level.
{% endhint %}

{% hint style="info" %}
If an **Optimization Policy is set through the exporter** when installing the PerfectScale Agent, **it cannot be modified in the UI afterward**. You can still change the policy by upgrading the exporter with the new value, or you can return it to the default by upgrading the exporter without specifying any value (this will also enable the option to change the custom time window through the UI).<br>

**Example:**

<pre class="language-yaml"><code class="lang-yaml">helm upgrade --install -n perfectscale --create-namespace perfectscale \
<strong>  --set settings.clusterOptimizationPolicy=MaxSavings \ # specify the desired Optimization Policy
</strong>  --reset-then-reuse-values \
perfectscale perfectscale/exporter
</code></pre>

{% endhint %}

6. Click the **`Generate Secret`** button.

{% hint style="warning" %}
For security reasons, PerfectScale does not store your secret key.
{% endhint %}

7. Execute the command from **`Deploy PerfectScale`***.*&#x20;

{% hint style="info" %}
If you are utilizing both **Windows** and **Linux** nodes within the cluster, it is necessary to run PerfectScale exporter on the Linux nodes. You can do it following the instructions -> [Mix of Windows and Linux nodes](#mix-of-windows-and-linux-nodes).
{% endhint %}

{% hint style="info" %}
PerfectScale supports Windows containers. To enable support for Windows containers, follow the instructions outlined here.
{% endhint %}

8. Click on the **`Finish and Close`** button.

{% hint style="info" %}
It is not supported to install multiple exporters in a single cluster, as it may result in unexpected results.
{% endhint %}

The newly added cluster will appear under the **`Clusters`** list in the **`Overview`** tab. Once the [**`Agent Status`**](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/visibility-and-optimization/clusters-metrics-overview#summary) becomes green, the cluster data will appear, which indicates successful cluster creation.&#x20;

<figure><img src="https://content.gitbook.com/content/zCh9aABpk7yLeToPr6vk/blobs/oEb8OX0exToSoMWgoTZ0/image.png" alt="Agent status"><figcaption><p>Agent status</p></figcaption></figure>

:bulb: Discover additional information regarding the [**Overview**](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/visibility-and-optimization/clusters-metrics-overview).

{% hint style="info" %}
Your cluster will become visible **only** after it starts transmitting data.
{% endhint %}

## Run PerfectScale exporter on specific nodes

PerfectScale allows running the exporter on particular nodes. To run the exporter on the specific nodes, use one of the following options:

1. `nodeSelector`  (in case there is no taint on the node).
2. `nodeSelector & toleration` (in case of taint on the node).

{% hint style="warning" %}
In case you are using **`zsh`** shell, make sure to add **`noglob`** before the helm command
{% endhint %}

```
helm upgrade --install -n perfectscale --create-namespace perfectscale \
  --set secret.create=true \
  --set secret.clientId=**** \
  --set secret.clientSecret=**** \
  --set settings.clusterName=name \
  --set nodeSelector.type=monitoring \
  --set tolerations[0].effect=NoSchedule,tolerations[0].key=monitoring,tolerations[0].operator=Exists \
  --set kube-state-metrics.nodeSelector.type=monitoring \
  --set kube-state-metrics.tolerations[0].effect=NoSchedule,kube-state-metrics.tolerations[0].key=monitoring,kube-state-metrics.tolerations[0].operator=Exists \
  perfectscale/exporter
```

## Mix of Windows and Linux nodes

{% hint style="warning" %}
If the cluster contains both **Windows** and **Linux** nodes, it is necessary to add the following extra `nodeSelector` to run **PerfectScale** exporter on the **Linux** nodes:\
\
\--set nodeSelector.beta\\\\.kubernetes\\\\.io/os=linux --set kube-state-metrics.nodeSelector.beta\\\\.kubernetes\\\\.io/os=linux
{% endhint %}

For Step 4 in the **`Onboarding a cluster`** scenario above, utilize the subsequent command to designate the Windows nodes:

```
helm upgrade --install -n perfectscale --create-namespace perfectscale \
 	--set secret.create=true \
        --set secret.clientId=**** \
        --set secret.clientSecret=**** \
        --set settings.clusterName=name \
        --set nodeSelector.beta\\.kubernetes\\.io/os=linux \
        --set kube-state-metrics.nodeSelector.beta\\.kubernetes\\.io/os=linux \
 	perfect scale/exporter
```

## GPU support

{% hint style="info" %}
GPU support is available starting with the exporter version 1.0.55.
{% endhint %}

PerfectScale’s advanced GPU support feature helps teams optimize resource-intensive applications like AI, machine learning, cloud computing, etc., ensuring better performance, reducing costs, and improving overall efficiency across the entire Kubernetes stack.

{% hint style="info" %}
PerfectScale now only supports NVIDIA Data Center GPU Manager (DCGM).&#x20;
{% endhint %}

In order to enable GPU support, in Step 4 in the [**Cluster configuration**](#cluster-configuration) instructions above, utilize the following command:

```
helm upgrade --install -n perfectscale --create-namespace perfectscale \
      --set secret.create=true \
      --set secret.clientId=**** \
      --set secret.clientSecret=**** \
      --set settings.clusterName=name \
      --set settings.dcgm.exporterEnabled=true \
      --set settings.dcgm.exporterNamespace="perfectscale" \
      --set settings.dcgm.exporterPort="9400" \
      --set settings.dcgm.exporterLabelSelector="app=nvidia-dcgm-exporter"     
      perfectscale/exporter
```

{% hint style="warning" %}
The **DCGM exporter is required**. Without it, PerfectScale will be unable to collect and display GPU utilization data.
{% endhint %}

## Java containers support

{% hint style="info" %}
The **Coroot agent** is disabled by default. Once enabled, PerfectScale automatically detects Java containers and starts collecting JVM metrics.&#x20;

Add the following parameter when deploying the PerfectScale agent to enable this feature:

```yaml
--set settings.corootNodeAgent.enabled=true
```

{% endhint %}

{% hint style="info" %}
Coroot supports only Linux nodes.
{% endhint %}

PerfectScale automatically identifies Java containers running in your Kubernetes environment and collects JVM metrics from them. By continuously analyzing them, PerfectScale provides granular visibility into resource usage, identifying potential bottlenecks. Based on this analysis, PerfectScale generates tailored recommendations to help ensure that your services remain efficient and maintain consistent performance.

PerfectScale starts collecting JVM metrics automatically. However, if for some reason you do not want PerfectScale to collect this data, you can disable it by turning off the deployment of `psc-coroot-node-agent` during agent installation:

```
--set settings.corootNodeAgent.enabled=false
```

### Deploy coroot pods to specific nodes

If your cluster includes both Linux and Windows nodes, make sure to set a nodeSelector for Linux when deploying workloads that are not Windows-compatible.

YAML values file example:

```yaml
coroot:
  nodeSelector:
    kubernetes.io/os: linux
```

Helm command example:

```
helm upgrade --install perfectscale ..... \
  --set coroot.nodeSelector."kubernetes\.io/os"=linux \
  perfectscale/exporter
```

To restrict workloads to a specific set of nodes (for example, those labeled `component=java`), you can combine multiple node selectors.

YAML values file example:

```
coroot:
  nodeSelector:
    kubernetes.io/os: linux
    component: java
```

Helm command example:

```
helm upgrade --install perfectscale ..... \
  --set coroot.nodeSelector."kubernetes\.io/os"=linux \
  --set coroot.nodeSelector.component=java \
  perfectscale/exporter
```

## Windows containers support

{% hint style="info" %}
Make sure you are using PerfectScale exporter version 1.0.53 or later to enable Windows containers support.
{% endhint %}

PerfectScale supports Windows-based containers, allowing you to optimize and manage them seamlessly. To enable this feature, as a Step 4 in a [cluster configuration](#cluster-configuration), execute the following command:

```
helm upgrade --install -n perfectscale --create-namespace perfectscale \
      --set secret.create=true \
      --set secret.clientId=**** \
      --set secret.clientSecret=**** \
      --set settings.clusterName=your-dev-cluster \
      --set settings.deployWindowsExporter=true \
      --set settings.windowsExporterEnabled=true \
      --set settings.windowsExporterNamespace="perfectscale" \
      --set settings.windowsExporterPort="9182" \
      --set settings.windowsExporterLabelSelector="app.kubernetes.io/name=prometheus-windows-exporter"     
      perfectscale/exporter
```

{% hint style="info" %}

* Make sure the Helm parameter `windowsExporterEnabled` is set to **`true`**
* If the windows-exporter should be deployed by the PerfectScale Helm set `deployWindowsExporter=`**`true`**. In that case, no additional configurations are needed, as the default values will be sufficient.<br>
* If `deployWindowsExporter` set t&#x6F;**`false`**, the additional parameters listed below need to be configured. \
  \
  Helm parameters should be configured according to the user’s environment:
  * `windowsExporterNamespace`
  * `windowsExporterPort`
  * `windowsExporterLabelSelector`
    {% endhint %}

## Size PerfectScale Agent

For large clusters, if you are not using automation, use PerfectScale’s recommendations for `psc-exporter` to properly size it.

## Uninstalling PerfectScale Agent

To uninstall the PerfectScale Agent, execute the following command

```yaml
helm -n perfectscale  uninstall psc-exporter
```
