Skip to content

KafkaSchema

Prerequisites

  • A Kubernetes cluster with the operator installed using helm, kubectl or kind (for local development).
  • A Kubernetes Secret with an Aiven authentication token.

Required permissions

To create and manage this resource, you must have the appropriate roles or permissions. See the Aiven documentation for details on managing permissions. For more precise access control, use permissions instead of roles.

Permissions

All of these permissions are required to create and manage this resource.

  • project:services:read
  • service:data:write

Usage example

apiVersion: aiven.io/v1alpha1
kind: KafkaSchema
metadata:
  name: my-schema
spec:
  authSecretRef:
    name: aiven-token
    key: token

  project: my-aiven-project
  serviceName: my-kafka
  subjectName: mny-subject
  compatibilityLevel: BACKWARD
  schema: |
    {
        "doc": "example_doc",
        "fields": [{
            "default": 5,
            "doc": "field_doc",
            "name": "field_name",
            "namespace": "field_namespace",
            "type": "int"
        }],
        "name": "example_name",
        "namespace": "example_namespace",
        "type": "record"
    }

Apply the resource with:

kubectl apply -f example.yaml

Verify the newly created KafkaSchema:

kubectl get kafkaschemas my-schema

The output is similar to the following:

Name         Service Name    Project             Subject        Compatibility Level    Version      
my-schema    my-kafka        my-aiven-project    mny-subject    BACKWARD               <version>    


KafkaSchema

KafkaSchema is the Schema for the kafkaschemas API.

Required

  • apiVersion (string). Value aiven.io/v1alpha1.
  • kind (string). Value KafkaSchema.
  • metadata (object). Data that identifies the object, including a name string and optional namespace.
  • spec (object). KafkaSchemaSpec defines the desired state of KafkaSchema. See below for nested schema.

spec

Appears on KafkaSchema.

KafkaSchemaSpec defines the desired state of KafkaSchema.

Required

  • project (string, Immutable, Pattern: ^[a-zA-Z0-9_-]+$, MaxLength: 63). Identifies the project this resource belongs to.
  • schema (string). Kafka Schema configuration should be a valid Avro Schema JSON format.
  • serviceName (string, Immutable, Pattern: ^[a-z][-a-z0-9]+$, MaxLength: 63). Specifies the name of the service that this resource belongs to.
  • subjectName (string, Immutable, MaxLength: 63). Kafka Schema Subject name.

Optional

  • authSecretRef (object). Authentication reference to Aiven token in a secret. See below for nested schema.
  • compatibilityLevel (string, Enum: BACKWARD, BACKWARD_TRANSITIVE, FORWARD, FORWARD_TRANSITIVE, FULL, FULL_TRANSITIVE, NONE). Kafka Schemas compatibility level.
  • schemaType (string, Enum: AVRO, JSON, PROTOBUF, Immutable). Schema type.

authSecretRef

Appears on spec.

Authentication reference to Aiven token in a secret.

Required

  • key (string, MinLength: 1).
  • name (string, MinLength: 1).