aiven command

The aiven commands can be used to give access to an already existing Aiven service by creating a AivenApplication in your specified namespace and extract credentials. Specifically the aiven create service command will create a personal, protected, and time-limited credential. For instance, credentials for nav-prod can only be generated in the prod clusters.

All commands have the following common flag available:

FlagRequiredShortDescription
environmentNo-eThe environment (Kubernetes context) to target.

create

The create command will give access to a personal, but time limited credentials. These credentials can be used to debug an Aiven kafka topic, or Opensearch instance. After creating credentials you need to use aiven get to save them locally.

bash
ArgumentRequiredDescription
serviceYesService to use, Kafka or OpenSearch supported.
usernameYesPreferred username.
namespaceYesKubernetes namespace where AivenApplication will be created.

Kafka example

To gain access to a specific Kafka topic be sure to update your topic resource and topic ACLs. Add username to spec.acl.application field in your topic.yaml and apply to your namespace.

yaml
bash
FlagRequiredShortDefaultDescription
poolNo-pnav-devKafka pool.
secret-nameNo-snamespace-username-randomstringPreferred secret-name.
expireNo1Time in days the secret should be valid.

OpenSearch example

bash

In OpenSearch, the username in the command is not related to the actual OpenSearch username, but used for internal purposes to identify the request. This is because the usernames on OpenSearch instances are pre-defined for each possible access level.

FlagRequiredShortDefaultDescription
accessNo-areadOne of: admin, read, write, readwrite.
instanceYes-iName of the instance. If your instance name is prefixed with opensearch-<team>-, you must exclude this prefix.
secretNo-snamespace-username-randomstringPreferred secret-name.
expireNo1Time in days the secret should be valid.

get

The get command extracts the credentials and puts them in a folder in the default location for temporary files 1. The created AivenApplication has sane default (days-to-live) set to 1 day.

bash
ArgumentRequiredDescription
serviceYesService to use, Kafka or OpenSearch supported.
secret-nameYesDefault secret-name or flag -s in create command.
namespaceYesKubernetes namespace for the created AivenApplication.

For Kafka we will create a Java properties file, KCat config file, and an .env file. For OpenSearch only .env file will be created. See Available output for better understanding of files created. All files will ble placed in a folder named aiven-secret-... in the default location for temporary files 1.

grant-access

The grant-access command updates the access control list (ACL) for specified Kubernetes resources (such as Kafka topics or streams). It requires a team to identify the target resource, using the --team (-t) flag.

The command ensures that only authorized users can access the specified resources according to the permissions you grant.

Stream

To grant a user access to a specific Kafka stream:

Ensure prerequisites:

  1. You have write access to the relevant stream.kafka.nais.io Kubernetes resource.
  2. The user has an Aiven service user. Create one if needed:
    bash
  3. Grant access:
bash
FlagRequiredShortDescription
teamYes-tThe team that owns the stream.kafka.nais.io.
environmentNo-eThe environment (Kubernetes context) to target.

The default permission level matches the application's own access.

Topic

To grant a user access to a specific Kafka topic:

Ensure prerequisites:

  1. You have write access to the relevant topic.kafka.nais.io Kubernetes resource.
  2. The user has an Aiven service user. Create one if needed:
    bash
  3. Grant access:
bash

* The --access flag is optional; if omitted, permission defaults to read.

FlagRequiredShortDefaultDescription
teamYes-tThe team that owns the topic.kafka.nais.io.
environmentNo-eThe environment (Kubernetes context) to target.
accessNo-areadPermission level for the topic.kafka.nais.io's ACL.

tidy

Removes folders in temporary files directory that starts with aiven-secret- 1.

bash

Available output

After Successful nais aiven create and nais aiven get commands, a set of files wil be available.

For Kafka

.env

  • client.keystore.p12
  • client.truststore.jks
  • kafka-ca.pem
  • kafka-certificate.crt
  • kafka-private-key.pem
  • kafka-secret.env
kafka-secret.env file
Properties

kcat

  • kafka-ca.pem
  • kafka-client-certificate.crt
  • kafka-client-private-key.pem
  • kcat.conf
kcat.conf file
Properties

The generated kcat.conf can be used with kcat to authenticate against the Aiven hosted topics in GCP.

Read more about kcat.conf configurable properties .

You can refer to generated config with -F flag:

sh

Alternatively, you can specify the same settings directly on the command line:

sh

For more details aiven-kcat

java

  • client.keystore.p12
  • client.truststore.jks
  • kafka.properties
kafka.properties file
txt

The kafka.properties file can be used with the official Kafka command-line tools included in the Kafka distribution, and with many other Java based tools/applications.

For OpenSearch

.env

  • opensearch-secret.env
opensearch-secret.env file
Properties

  1. See https://pkg.go.dev/os#TempDir