# Accessing topics from an application

This guide shows you how to access Kafka topics from your application.

## Prerequisites

You need an existing topic to access. See [Create a Kafka topic](/persistence/kafka/how-to/create.md) for how to create a topic.

## Enable access to the relevant pool in your workload definition

> **.nais/app.yaml**
> ```yaml
>   apiVersion: nais.io/v1alpha1
>   kind: Application
>   metadata:
>     name: <MY-APP>
>     namespace: <MY-TEAM>
>     labels:
>       team: <MY-TEAM>
>   spec:
>     kafka:
>       pool: <MY-POOL>
> ```

Select a `pool` from one of the [available pools](/persistence/kafka/reference/pools.md).

## Grant access to the topic

The owner of the topic must [grant your application access to the topic](/persistence/kafka/how-to/manage-acl.md).

## Configure your application

Aiven has written several articles on how to configure your application.
We use SSL, so ignore the SASL-SSL examples:

- [Java](https://aiven.io/docs/products/kafka/howto/connect-with-java)
- [Python](https://aiven.io/docs/products/kafka/howto/connect-with-python)
- [Node.js](https://aiven.io/docs/products/kafka/howto/connect-with-nodejs)
- [Go](https://aiven.io/docs/products/kafka/howto/connect-with-go)

For all available environment variables, see the [reference](/persistence/kafka/reference/environment-variables.md).

We recommend following the [application design guidelines](/persistence/kafka.md#application-design-guidelines) for how to configure your application.

## Apply the application

**Automatically**

Add the file to your application repository to deploy with [Nais github action](/build/how-to/build-and-deploy.md).

**Manually**

```bash
kubectl apply -f ./nais/app.yaml --namespace=<MY-TEAM> --context=<MY-ENV>
```
