# Onboarding with ArgoCD

## Installing agent with ArgoCD

To install the agent with ArgoCD, use the following instructions.

1. Complete 1-5 steps from [Onboarding a cluster](https://docs.perfectscale.io/getting-started/how-to-onboard-a-cluster).
2. Make sure to save the clientId and clientSecret, as we will require it later on. <br>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FdWMvC0BMqWBk3aLWWgvX%2Fimage.png?alt=media&#x26;token=4eee8ff9-a009-4bc6-a97c-7c9ad9b27173" alt="Credentials" width="563"><figcaption><p>Credentials</p></figcaption></figure>
3. Download the most recent Helm chart that is used for ArgoCD to your repository (for this guide, we'll be utilizing <git@github.com>:<mark style="background-color:yellow;">perfectscale/ps-kube.git</mark>).

```
helm fetch perfectscale/exporter
tar -xf exporter-*.tgz && rm exporter-*.tgz
```

4. Create an additional (for example, `dev.yaml` value) file with the following content&#x20;

{% hint style="danger" %}
**`clusterName`**&#x69;s mandatory. PerfectScale Agent will not work if the cluster name is not provided.
{% endhint %}

```
cat > exporter/dev.yaml <<EOF
secret:
  create: true
  name: "perfectscale-secret"
  clientSecret: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx"
  clientId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx"
settings:
  clusterName: "xxx"
EOF
```

:bulb:Replace `clientSecret` and `clientId` with copied before.

{% hint style="success" %}
If you have already installed the agent and need to recall the **clusterName**, **clientID**, and **clientSecret**, you can retrieve them using the following commands accordingly:

`kubectl -n perfectscale describe deployment perfectscale-exporter | grep CLUSTER_NAME`

`kubectl -n perfectscale get secret perfectscale-exporter-secret -o jsonpath="{.data.clientId}" | base64 --decode`\
\
`kubectl -n perfectscale get secret perfectscale-exporter-secret -o jsonpath="{.data.clientSecret}" | base64 --decode`
{% endhint %}

5. Push all the modifications to your git repository, which is accessible by ArgoCD.

{% hint style="info" %}
There are two methods to add an application to ArgoCD: [using the WEB UI](#web-ui) or [creating a YAML CRD file](#crd). You can select the approach that best suits your infrastructure.
{% endhint %}

### WEB UI

1. Login to the ArgoCD Web UI interface and click the **`NEW APP`** button.<br>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FNjxOmSQLIAbkIqAhZnMd%2Fimage.png?alt=media&#x26;token=35ad4b28-59a6-49ae-a192-81b62dc24b2f" alt="New app ArgoCD"><figcaption><p>New app ArgoCD</p></figcaption></figure>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2Ff9PiuD2K9j7vSwwmgwoQ%2Fimage.png?alt=media&#x26;token=f1742a60-8fc8-4c24-b335-f0f32f62dab5" alt="New app form1"><figcaption><p>New app form1</p></figcaption></figure>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2F2PjPuUN1CNdd89Z5VxL7%2Fimage.png?alt=media&#x26;token=80e7b016-395e-4b93-a05e-ddfc642567b2" alt="New app form2"><figcaption><p>New app form2</p></figcaption></figure>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2F9ChEth9XzREzXpBot3bF%2Fimage.png?alt=media&#x26;token=6a722647-2bf5-4133-838d-482fbded9a66" alt="New app form3"><figcaption><p>New app form3</p></figcaption></figure>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2Fy2oxfIoKmnRinUTBsseF%2Fimage.png?alt=media&#x26;token=26bbcc78-d958-414b-9924-5a87358204d7" alt="New app form4"><figcaption><p>New app form4</p></figcaption></figure>

2. Once the creation process is completed, you will see the OutOFSync application.<br>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FXd33sukSbJvHT9wnwIc1%2Fimage.png?alt=media&#x26;token=7e3d0b88-4619-4897-b95a-fb7d9af9525a" alt="OutOFSync application"><figcaption><p>OutOFSync application</p></figcaption></figure>

3. Synchronize the application.<br>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FYkcfImWxV8TwCsvWxIqf%2Fimage.png?alt=media&#x26;token=28078220-d924-49a1-b1e6-741a34fba4cb" alt="Application synchronization"><figcaption><p>Application synchronization</p></figcaption></figure>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FyfUMku3zQsgABKBrgZWb%2Fimage.png?alt=media&#x26;token=1a46700b-9fcf-4221-8318-90cc4b304a77" alt="Synchronized application"><figcaption><p>Synchronized application</p></figcaption></figure>

4. Ensure that all pods are running.<br>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FclX9F1hy0CoyWAm1skXX%2Fimage.png?alt=media&#x26;token=67eae521-0ab5-4954-b205-fedb9c6ec9e3" alt="Check running pods1"><figcaption><p>Check running pods1</p></figcaption></figure>

### CRD

1. Create a Custom Resource Definition file for the ArgoCD.

```
cat > perfectscale.yaml <<EOF
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  labels:
    argocd.argoproj.io/instance: argocd-applications
  name: perfectscale-crd
spec:
  destination:
    namespace: perfectscale
    server: https://kubernetes.default.svc
  project: default
  source:
    helm:
      valueFiles:
      - values.yaml
      - dev.yaml
    path: exporter
    repoURL: git@github.com:perfectscale/ps-kube.git
    targetRevision: HEAD
  syncPolicy:
    syncOptions:
    - CreateNamespace=true
EOF
```

2. Apply the following command in the cluster application.

```
kubectl apply -f  perfectscale.yaml -n argo-cd
```

:bulb: Replace the namespace for **`argo-cd`** with the one where you have stored all of your applications.

3. Check a new application in the ArgoCD.<br>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FxxcDulBrIv0bZbTShxg7%2Fimage.png?alt=media&#x26;token=2525680b-ceb6-419b-aa9e-28aad2ced9a5" alt="New application in ArgoCD"><figcaption><p>New application in ArgoCD</p></figcaption></figure>

4. Synchronize the application.<br>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FEZzJj4PMKwwFgw7YlDxi%2Fimage.png?alt=media&#x26;token=ef902b70-585f-4d25-873a-82c85eea42ac" alt="Sync the application"><figcaption><p>Sync the application</p></figcaption></figure>

5. Ensure that all pods are running.<br>

   <figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FSauoeBYIUH1BuhjypfIf%2Fimage.png?alt=media&#x26;token=3b1f5bb7-8ac4-447b-b7a4-77e271602739" alt="Check running pods2"><figcaption><p>Check running pods2</p></figcaption></figure>

   <br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.perfectscale.io/getting-started/onboarding-with-argocd.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
