# \[AIAB-04] Setup Akamas

### Setup Akamas

Notice: if you installed the cluster with Minikube by following the steps documented in the section Build Minikube Cluster, then you do not need to set up Akamas. Thus, you can skip to the next section, Verify Akamas, to verify that everything is working fine.

As described in the section Architecture Overview, Akamas needs to communicate with the cluster to apply new configurations of the *Online Boutique* using the `kubectl` tool. Therefore, if you are optimizing your own Kubernetes cluster, you need to make sure that Akamas can interact with it.

First, you need to go to your Akamas-in-a-box machine and copy your kubeconfig file (i.e., `~/.kube/config`) in the `/akamas-config` folder. Then, you have to ensure that the container named *benchmark* has the credentials to access the cluster. The credentials to pass could differ depending on your cluster provider. The examples here below are specific to an EKS cluster and other providers.

#### EKS Cluster <a href="#user-content-eks-cluster" id="user-content-eks-cluster"></a>

Please copy & paste the following command and substitute your AWS credentials in place of the placeholders. It will create the file `/akamas-config/envs` that contains the variables required to communicate with the cluster:

```bash
cat << EOF > /akamas-config/envs
AWS_ACCESS_KEY_ID=<YOUR_AWS_ACCESS_KEY_ID>
AWS_SECRET_ACCESS_KEY=<YOUR_AWS_SECRET_ACCESS_KEY>
AWS_DEFAULT_REGION=<YOUR_AWS_DEFAULT_REGION>
EOF
```

#### Other Providers <a href="#user-content-other-providers" id="user-content-other-providers"></a>

You might write a file `envs` as above in the `/akamas-config` directory and put there all the environment variables needed to connect to your cluster as in the example below.

```bash
cat << EOF > /akamas-config/envs
<ENV_KEY>=<ENV_VALUE>
...
EOF
```

The setup is now complete. You can now proceed to the next section to verify it.

### Verify Akamas Setup <a href="#user-content-verify-akamas-setup" id="user-content-verify-akamas-setup"></a>

Duration: 01:00

You need to make sure that Akamas can interact with the target cluster. Check that:

* The **benchmark** container in your Akamas-in-a-box machine can run `kubectl` commands against your cluster.
* The **benchmark** container can reach your cluster through HTTP.

To check that the container can connect to your cluster run the following command and verify that you can see your Kubernetes namespaces:

```bash
docker exec -it --env-file /akamas-config/envs benchmark bash -c "kubectl get namespaces --kubeconfig /kubeconfig/config"
```

Next, you need to check that you can reach your Prometheus and the loadgenerator from the benchmark container.

To verify that you can communicate with Prometheus try to run the following command, substituting the `CLUSTER_IP` placeholder with your public cluster IP:

```bash
docker exec -it benchmark bash -c "curl http://<CLUSTER_IP>:30900"
```

You should see the output:

```html
<a href="/graph">Found</a>.
```

Lastly, to verify that you can connect with the loadgenerator run the following command, substituting the `CLUSTER_IP` placeholder with your public cluster IP:

```bash
docker exec -it benchmark bash -c "curl -w '\n' http://<CLUSTER_IP>:30899/stats/reset"
```

You should see the output:

```
ok
```

At this point, Akamas is correctly configured to interact with the target cluster, and you can start modeling and then optimizing your cluster in Akamas.
