# Installation

## Install Datafy

Datafy should be installed on any nodes or instances with EBS volumes attached that you want Datafy to monitor or manage.

All installations include two parameters:

* `$VERSION` or `$HELM_VERSION` **-** The version number of the agent (in EC2) or Helm chart (in K8s) to be installed. For consistent behavior, this should always be specified.
* `$TOKEN` - Security token used for identification, associated with the relevant AWS account. The security token can be [generated by an admin](/set-up-and-installation/datafy-installation/token-generation.md) through the Datafy dashboard.

{% hint style="info" %}
If you are installing on an instance where Datafy is already installed, check out [how to upgrade](/set-up-and-installation/upgrading-datafy.md)
{% endhint %}

### EC2 Instance <a href="#ec2-installation" id="ec2-installation"></a>

Datafy is installed on EC2s as a Docker image. If not already installed on your instance, [install Docker](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-docker.html) before installing Datafy.

Run the following CLI command on your instance to install Datafy:

{% tabs %}
{% tab title="Sensor" %}
{% code overflow="wrap" %}

```sh
curl -sSfL https://agent.datafy.io/install?version=$VERSION | AGENT_MODE="sensor" TOKEN=$TOKEN sh
```

{% endcode %}
{% endtab %}

{% tab title="AutoScaler" %}
{% code overflow="wrap" %}

```sh
curl -sSfL https://agent.datafy.io/install?version=$VERSION | AGENT_MODE="autoscaler" TOKEN=$TOKEN sh
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
The install command downloads and runs an install script that ensures your instance is supported by Datafy, and then installs the requested version using Docker.
{% endhint %}

{% hint style="success" %}
Check out [Deployment Examples](/resources/deployment-examples.md) for examples how to install Datafy with the deployment tools you already use
{% endhint %}

### Kubernetes Cluster

You can install Datafy using a single line command or with a Helm chart directly.

{% hint style="warning" %}
When installing Autoscaler, make sure that all of the nodes in the relevant cluster or node group are [supported](/set-up-and-installation/supported-infrastructure.md).
{% endhint %}

#### Helm Chart Installation

Datafy can be installed directly via a Helm chart. See the [latest Helm chart documentation](https://github.com/datafy-io/datafy-agent-helm/) for additional installation parameters and versioning.

The Helm chart installs the Datafy agent as a [DaemonSet](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/) on every node in your cluster. For AutoScaler installations, it also installs a Datafy controller Deployment, and adds a `datafy-proxy` sidecar container to your existing EBS CSI driver pods — see [AutoScaler on Kubernetes](/how-it-works/autoscaler-on-kubernetes.md) for what each component does. If the installation fails, Helm will roll back the cluster to the state it was in before the installation began.

{% stepper %}
{% step %}
**Add Datafy Repo**

```bash
helm repo add datafyio https://helm.datafy.io/datafy-agent
helm repo update
```

{% endstep %}

{% step %}
**Install Datafy**

{% tabs %}
{% tab title="Sensor" %}
{% code overflow="wrap" %}

```bash
helm upgrade --install datafy-agent \
--version "$HELM_VERSION" datafyio/datafy-agent \
--namespace datafy-agent --create-namespace \
--set agent.mode="sensor" \
--set agent.token="$TOKEN" \
--atomic   
```

{% endcode %}
{% endtab %}

{% tab title="AutoScaler" %}
{% code overflow="wrap" expandable="true" %}

```bash
helm upgrade --install datafy-agent \
--version "$HELM_VERSION" datafyio/datafy-agent \
--namespace datafy-agent --create-namespace \
--set agent.mode="autoscaler" \
--set agent.token="$TOKEN" \
--atomic
```

{% endcode %}

{% hint style="warning" %}
To successfully install Autoscaler on nodes running **Bottlerocket**, you must disable kernel lockdown prior to installation. Add the following configuration to the node's user data:

{% code overflow="wrap" %}

```bash
[settings.kernel]
lockdown = "none"
```

{% endcode %}
{% endhint %}
{% endtab %}
{% endtabs %}
{% endstep %}
{% endstepper %}

#### Single-Line Installation

{% hint style="info" %}
If your cluster is running Bottlerocket, use the Helm chart installation above
{% endhint %}

{% tabs %}
{% tab title="Sensor" %}
{% code overflow="wrap" %}

```bash
curl -sSfL https://agent.datafy.io/install-k8s?version="$HELM_VERSION" | AGENT_MODE="sensor" TOKEN="$TOKEN" sh
```

{% endcode %}
{% endtab %}

{% tab title="AutoScaler" %}
{% code overflow="wrap" %}

```sh
curl -sSfL https://agent.datafy.io/install-k8s?version="$VERSION" | AGENT_MODE="autoscaler" TOKEN="$TOKEN" sh
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Validate Installation

You're all set up!

Once you've successfully completed the installation, you can see the utilization of the volumes attached to instances Datafy is installed on in the [Datafy dashboard](https://app.datafy.io/fleet-manager).

If you've installed Autoscaler, you can now use the ["AutoScale" toggle or create an autoscaling rule to activate autoscaling](/volume-lifecycle/managing-autoscaling-volumes.md#activating-autoscaling) for the selected volumes.


---

# 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.datafy.io/set-up-and-installation/datafy-installation/installation.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.
