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. This uses your currently configured kubectl context, so in order for it to work you need to select a suitable context first. For instance, credentials for nav-prod can only be generated in the prod clusters.

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.
expireNo-e1Time 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.
secretNo-snamespace-username-randomstringPreferred secret-name.
expireNo-e1Time 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.

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