# EKS Add-on

Amazon EKS add-ons provide installation and management of a curated set of add-ons for Amazon EKS clusters, including the Rafay Management Operator. Amazon EKS add-ons allow administrators to reduce the amount of work required in order to install, configure, and update cluster capabilities.

---

## Pre-Requisites

- Subscription to [Rafay Kubernetes Automation Platform](https://aws.amazon.com/marketplace/pp/prodview-wssbcuxrwpnh4?applicationId=AWS-Marketplace-Console&ref_=beagle&sr=0-2)

- An Amazon EKS cluster with a configured OIDC provider [Amazon EKS OIDC configuration](https://aws.amazon.com/blogs/opensource/introducing-fine-grained-iam-roles-service-accounts/)

- From Rafay Console, create an [imported Amazon EKS cluster](https://docs.rafay.co/clusters/import/wizard/) using the same cluster name.

- Whitelist connectivity to Rafay SaaS controller, more detailed requirements here [Rafay whitelist](https://docs.rafay.co/security/whitelist/)
  - Port 443 outbound on cluster
  - Network firewall configuration to allow the path to Rafay SaaS controller
  - Whitelist Rafay SaaS controller
  - Whitelist Rafay services FQDNs

---

## Install Rafay Operator Add-on using AWS console

- Select your desired cluster in the Amazon EKS console.
- Select the **Add-ons** tab and click **Get more add-ons**
- Search AWS Marketplace add-ons for **Rafay Kubernetes Operations Platform**.

- For the version, select the latest version.
- Download the Add-on configuration values file using the Rafay API. Refer to section **Retrieving Add-on Configurations Value** below for additional instruction.
- On the EKS console, under **optional configuration settings** -> **Configuration values**, paste the downloaded values from the previous step.

- Select Next and Select Create to create the Rafay Operator addon on the EKS cluster.

---

## Installing Rafay Operator Add-on using AWS CLI

Run the following command to enable the Rafay Operator add-on for your Amazon EKS cluster

- Download the Add-on configuration values file using the Rafay API. Refer to section **Retrieving Add-on Configurations Value** below for additional instruction.
- Write the downloaded values into a file in your local terminal.
- Install Rafay EKS addon using AWS CLI

```
    aws eks create-addon --cluster-name <CLUSTER_NAME> --addon-name rafay-systems_rafay-operator --addon-version v1.0.6-eksbuild.1 --configuration-values file:///<PATH_TO_VALUES_FILE> --region <AWS_REGION>
```

---

## Validating the Install

To monitor the installation status, run the following command:

```
kubectl get pods -n rafay-system --watch
```

It might take a few minutes for all pods to initialize, but eventually, all pods should indicate a Running status. If the pods are stuck in any other state, please follow the [documentation](https://docs.rafay.co/clusters/import/debug/) to debug further.

---

## Retrieving Add-on Configurations Values

The add-on configuration value can be retrieved via Rafay API. You can use the built-in **Swagger UI** or regular **CURL** command.

### Using Swagger UI

Follow the instruction below to retrieve the configuration via Swagger UI:

Each cluster is grouped by the project in Rafay console. Locate the Project id by using the Project API: [https://console.rafay.dev/swagger-ui/#/Projects/list_projects](https://console.rafay.dev/swagger-ui/#/Projects/list_projects)

Select the **try-out** button and select **Execute**.

Locate the project id from the response body in the Swagger UI.

To register the new cluster, configuration values is available from the Cluster API: [https://console.rafay.dev/swagger-ui/#/Cluster/DownloadValuesYaml](https://console.rafay.dev/swagger-ui/#/Cluster/DownloadValuesYaml).

Select the **try-out** button and enter the required parameters, including the project id and the cluster name.

Select **Execute** and copy the entire response body.

Use this configuration value when setting up Rafay Add-on in the EKS console / API / CLI.

### Using CURL

Use the following CURL command to retrieve the Addon configuration values. You need to provide the `PROJECT_ID` and `CLUSTER_NAME` as part of the requests. To learn more on how to use Rafay API, check the [API documentation](https://docs.rafay.co/automation/api/apis/)

```
curl -X 'GET' 'https://console.rafay.dev/v2/scheduler/project/<PROJECT_ID>/cluster/<CLUSTER_NAME>/download/valuesyaml?json=false' -H 'accept: application/x-rafay-yaml' -H 'X-RAFAY-API-KEYID: <RAFAY_API_KEY>'
```
