Kafkarator is a Kubernetes operator on the NAIS platform, providing self-service functionality for Aiven-hosted Kafka through Kubernetes resources.
Kafkarator defines a Kubernetes custom resource, kafka.nais.io/Topic. When users create or update this resource,
Kafkarator translates it to Aiven topics and ACL entries.
- User documentation
- Features
- Architecture & Design
- Configuration
- Usage Example
- Scripts & Utilities
- Developer documentation
- Helm Charts
- Verifying Images
- Contributing
- Links
- Declarative management of Kafka topics and ACLs via Kubernetes CRDs.
- Automatic synchronization between Kubernetes resources and Aiven Kafka.
- Support for both topic and stream resources.
- Canary deployment and monitoring via the
canarycomponent. - Helm charts for easy deployment and configuration.
- Security checks, static analysis, and SBOM attestation in CI.
- Built as a Kubernetes operator using Go and controller-runtime.
- Uses a custom resource definition (CRD)
kafka.nais.io/Topicfor declarative Kafka management. - Architecture Decision Records (ADRs) are maintained for key design decisions.
- Note: Future ADRs are maintained in the PIG repository.
- Most configuration is handled via environment variables, often with the
CANARY_orFEATURE_prefix. - Example variables:
CANARY_KAFKA_BROKERS: Comma-separated list of Kafka broker addresses.CANARY_KAFKA_CERTIFICATE_PATH,CANARY_KAFKA_KEY_PATH,CANARY_KAFKA_CA_PATH: Paths to Kafka TLS credentials.CANARY_KAFKA_TOPIC: Default topic for canary messages.CANARY_METRICS_ADDRESS: Address for Prometheus metrics endpoint.FEATURE_GENERATED_CLIENT: Feature flag for enabling generated client code.
See the cmd/canary/main.go and cmd/kafkarator/feature_flags.go for all available flags and environment variables.
Deploy Kafkarator to your Kubernetes cluster using the provided Helm charts. Then create a KafkaTopic resource:
apiVersion: kafka.nais.io/v1
kind: Topic
metadata:
name: my-topic
namespace: my-team
spec:
pool: nav-dev
config:
partitions: 3
replication: 2
acl:
- access: read
application: my-app
team: my-teamKafkarator will automatically create the topic and set up ACLs in Aiven.
For more examples, see the examples/ directory.
The scripts/ directory contains Python utilities for investigating and cleaning up Kafka users and ACLs. Key scripts include:
investigate_app.py: Investigate service users and ACLs for a given app/team.user_cleaner.py: Find and optionally remove unused Kafka users.find_app.py: Search for secrets and users related to a specific app.
- mise (for tool and task management)
- Earthly (for reproducible builds)
- Go (see
mise.tomlfor version) - Helm (for chart linting)
-
Build Docker images:
./earthlyw +docker
This uses the
earthlywwrapper to ensure you always use the correct Earthly version for reproducible builds. It builds Docker images for bothkafkaratorandcanary. -
Run all code checks (lint, static analysis, security, Helm lint):
mise run check
This runs all checks defined in
.mise-tasks/check/(deadcode, gosec, staticcheck, vulncheck, helm-lint, etc). -
Run tests:
mise run testOr with coverage (if you have tests):
mise run test -- --coverage -
Build locally (binaries):
make kafkarator make canary
This builds the binaries directly using Go.
Helm charts for kafkarator, kafka-canary, and kafka-canary-alert are in the charts/ directory. Lint them with:
mise run check:helm-lintTo install a chart (example):
helm install kafkarator charts/kafkaratorThe images are signed "keylessly" using Sigstore cosign.
To verify their authenticity run (replace <shasum> with the actual image digest):
cosign verify \
--certificate-identity "https://github.com/nais/kafkarator/.github/workflows/main.yml@refs/heads/master" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
europe-north1-docker.pkg.dev/nais-io/nais/images/kafkarator@sha256:<shasum>The images are also attested with SBOMs in the CycloneDX format. You can verify these by running:
cosign verify-attestation --type cyclonedx \
--certificate-identity "https://github.com/nais/kafkarator/.github/workflows/main.yml@refs/heads/master" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
europe-north1-docker.pkg.dev/nais-io/nais/images/kafkarator@sha256:<shasum>- Please run
mise run checkandmise run testbefore submitting a PR. - See
.mise-tasks/for all available tasks. - For questions, see NAIS Slack or open an issue.
- Open issues or pull requests for new features or bug reports.
This project is licensed under the MIT License. See the LICENSE file for details.
