Skip to content

Accessing topics from an application outside NAIS

This guide will show you how to access a Kafka topic from an application outside NAIS clusters.

Enable access to the relevant pool in your manifest

.nais/aivenapp.yaml
apiVersion: aiven.nais.io/v1
kind: AivenApplication
metadata:
  name: <MY-APP>
  namespace: <MY-TEAM>
spec:
  kafka:
    pool: <MY-POOL> (TODO: link to available tenant pools)
  secretName: <MY-UNIQUE-SECRET-NAME>
  protected: true

Info

The secretName must be a valid DNS label, and must be unique within the namespace.

Apply the AivenApplication

Add the file to your application repository, alongside nais.yaml to deploy with NAIS github action.

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

Extract the value of the generated secret

kubectl get secret <MY-UNIQUE-SECRET-NAME> --namespace <MY-TEAM> --contect <MY-ENV> -o jsonpath='{.data}' 

Make the values available to your application.

Grant access to the topic

The owner of the topic must grant your application access to the topic.