# Accessing Akamas

To interact with your Akamas instance you need the UI and API Gateway to be accessible from outside the cluster. This means you need to expose the `ui` and `kong` service respectively (although a minimal configuration only requires exposing the `ui` service, since it can forward requests to the API Gateway through the path `/akapi`).

Kubernetes offers different options to expose a service outside of the cluster. The following is a list of the supported ones, with examples of how to configure them to work in your chart release:

* [Port Forwarding](#port-forwarding)
* [LoadBalancer](#loadbalancer)
* [Ingress](#ingress)
* [NodePort](#nodeport)

### Port Forwarding

By default, Akams uses Cluster IPs for its services, which only allow communication inside the cluster. Still, you can leverage Kubectl's *port-forward* to create a private connection and expose any internal service on your local machine.

This solution is suggested to perform quick tests without the need of exposing the application, or in scenarios where cluster access to the public is not allowed.

To make the Akamas UI accessible on `http://localhost:8000`, run the following command:

```bash
kubectl port-forward service/ui 8000:http
```

To interact with the Akamas CLI you can use the URL `http://localhost:8000/akapi`, or expose the `kong` service in the same way.

Refer to the official [kubernetes documentation](https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/) for more details about port-forwarding.

### Load Balancer

Load Balancers expose services outside the cluster. This solution is often used with clusters managed by cloud providers such as Amazon EKS or Google Kubernetes Engine (GKE).

You can expose the Akamas UI through a Load Balancer by adding the snippet below to the `akamas.yaml` file from the previous section, and re-running [the install command](https://docs.akamas.io/akamas-docs/3.2.0/installing-akamas/install-akamas/online#start-the-installation) to update the configuration.

```yaml
ui:
  service:
    type: "LoadBalancer"
```

To get the address of the load balancer run the command:

```bash
kubectl get svc ui -o 'custom-columns=NAME:metadata.name,TYPE:spec.type,HOSTNAME:status.loadBalancer.ingress[].hostname'
```

For more details on Load Balancers refer to the [official kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer).

### Ingress

An Ingress is a Kubernetes object that provides service access, load balancing, and SSL termination to kubernetes services.

You can expose the Akamas UI through an *Ingress* by adding the snippet below to the `akamas.yaml` file from the previous section. After adding to `className` one of the ingress controllers available on the cluster, re-run [the install command](https://docs.akamas.io/akamas-docs/3.2.0/installing-akamas/install-akamas/online#start-the-installation) to update the configuration.

```yaml
ui:
  ingress:
    enabled: true
    className: "<class-name>"
    hosts:
      - host: "<dns-name>"
        paths:
          - path: /
            pathType: Prefix
```

You can also configure a certificate on the Ingress: refer to [HTTPS configuration section](https://docs.akamas.io/akamas-docs/3.2.0/installing-akamas/kubernetes/secure-https-configuration) for instructions.

Refer to the [official kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/ingress/) for more details on Ingresses.

### NodePort

Node Ports make services accessible on specific ports of any node of the cluster.

You can expose the Akamas UI through a NodePort by adding the snippet below to the `akamas.yaml` file from the previous section, and re-running [the install command](https://docs.akamas.io/akamas-docs/3.2.0/installing-akamas/install-akamas/online#start-the-installation) to update the configuration.

```yaml
ui:
  service:
    type: "NodePort"
    http:
      nodePort: "30010"
```

The Akamas UI will be accessible on any cluster node at `http://<cluster-node>:30010`. You can also omit the `http.nodePort` field and let Kubernetes automatically select a random port.

Refer to the [official kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) for more information on Node Ports.
