strimzi

package module
v1.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2026 License: BSD-2-Clause Imports: 8 Imported by: 0

README

Strimzi Go Client Library

Go Reference Go Report Card

A Go library that provides Kubernetes client bindings for Strimzi Kafka custom resources. This library generates typed Go clients for Kafka CRDs (Custom Resource Definitions) using Kubernetes code generation tools, enabling programmatic management of Strimzi Kafka resources in your Go applications.

Features

  • 🎯 Typed Kubernetes Clients: Auto-generated clientsets, informers, and listers for Strimzi Kafka CRDs
  • 🔧 Code Generation: Built using Kubernetes client-go code generation tools
  • 🧪 Well Tested: Comprehensive test coverage using Ginkgo v2 and Gomega
  • 📦 Easy Integration: Simple API for creating and managing Kafka resources
  • 🏗️ Production Ready: Follows Kubernetes client-go patterns and conventions

Installation

go get github.com/bborbe/strimzi

Quick Start

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/bborbe/strimzi"
)

func main() {
    ctx := context.Background()
    
    // Create a clientset (uses default kubeconfig)
    clientset, err := strimzi.CreateClientset(ctx, "")
    if err != nil {
        log.Fatal(err)
    }
    
    // List Kafka topics
    topics, err := clientset.KafkaV1beta2().KafkaTopics("kafka").List(ctx, metav1.ListOptions{})
    if err != nil {
        log.Fatal(err)
    }
    
    fmt.Printf("Found %d Kafka topics\n", len(topics.Items))
}

API Documentation

For comprehensive API documentation, visit pkg.go.dev/github.com/bborbe/strimzi.

Development

This project uses standard Go development tools and follows Benjamin Borbe's coding guidelines.

Prerequisites
  • Go 1.24+
  • Kubernetes cluster with Strimzi operator installed (for integration testing)
Building
make precommit  # Run all quality checks
make test       # Run tests
make generatek8s # Regenerate Kubernetes client code
Testing
# Run all tests
make test

# Run specific tests
ginkgo run pkg/

# Generate mocks
go generate ./...

Project Structure

  • k8s/apis/kafka.strimzi.io/v1beta2/ - API definitions and types for Kafka custom resources
  • k8s/client/ - Auto-generated Kubernetes clients (clientset, informers, listers, apply configurations)
  • strimzi_clientset.go - Main entry point for creating clientsets
  • hack/update-codegen.sh - Kubernetes code generation script

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Run quality checks (make precommit)
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

License

This project is licensed under the BSD License - see the LICENSE file for details.

Documentation

Overview

Package strimzi provides Kubernetes client bindings for Strimzi Kafka custom resources.

This package generates typed Go clients for Kafka CRDs (Custom Resource Definitions) using Kubernetes code generation tools, enabling programmatic management of Strimzi Kafka resources in your Go applications.

Example usage:

ctx := context.Background()
clientset, err := strimzi.CreateClientset(ctx, "")
if err != nil {
    log.Fatal(err)
}

topics, err := clientset.KafkaV1beta2().KafkaTopics("kafka").List(ctx, metav1.ListOptions{})
if err != nil {
    log.Fatal(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KafkaTopicInterface

type KafkaTopicInterface = v1beta2.KafkaTopicInterface

KafkaTopicInterface is a type alias for v1beta2.KafkaTopicInterface that enables mock generation using counterfeiter.

type KafkaV1beta2Interface added in v1.6.1

type KafkaV1beta2Interface v1beta2.KafkaV1beta2Interface

KafkaV1beta2Interface is a type alias for v1beta2.KafkaV1beta2Interface that enables mock generation using counterfeiter.

type StrimziClientset added in v1.5.4

type StrimziClientset = versioned.Interface

StrimziClientset provides access to all Strimzi Kafka custom resource clients. It includes typed clients for KafkaTopics and other Strimzi resources.

func CreateClientset

func CreateClientset(ctx context.Context, kubeconfig string) (StrimziClientset, error)

CreateClientset creates a new Strimzi clientset for interacting with Kafka custom resources.

Parameters:

  • ctx: Context for the operation
  • kubeconfig: Path to kubeconfig file. If empty, uses default kubeconfig resolution (in-cluster config if running in pod, or ~/.kube/config if running locally)

Returns:

  • StrimziClientset: A clientset for accessing Strimzi Kafka resources
  • error: Any error that occurred during clientset creation

Example:

// Use default kubeconfig
clientset, err := strimzi.CreateClientset(ctx, "")

// Use specific kubeconfig file
clientset, err := strimzi.CreateClientset(ctx, "/path/to/kubeconfig")

type TopicDeployer

type TopicDeployer interface {
	// Deploy creates or updates a KafkaTopic resource in Kubernetes.
	// If the topic doesn't exist, it will be created. If it exists, it will be updated
	// with the new configuration while preserving the resource version.
	Deploy(ctx context.Context, topic v1beta2.KafkaTopic) error

	// Undeploy removes a KafkaTopic resource from Kubernetes.
	// If the topic doesn't exist, the operation succeeds silently.
	Undeploy(ctx context.Context, namespace string, name string) error
}

TopicDeployer provides operations for deploying and managing Kafka topics in Kubernetes. It handles both creation and updates of KafkaTopic custom resources, as well as their removal.

func NewTopicDeployer

func NewTopicDeployer(
	clientset versioned.Interface,
) TopicDeployer

NewTopicDeployer creates a new TopicDeployer instance.

Parameters:

  • clientset: Strimzi clientset for interacting with KafkaTopic resources

Returns:

  • TopicDeployer: A new deployer instance for managing Kafka topics

Directories

Path Synopsis
k8s
apis/kafka.strimzi.io/v1beta2
Package v1beta2 is the v1beta2 version of the API.
Package v1beta2 is the v1beta2 version of the API.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/kafka.strimzi.io/v1beta2
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/kafka.strimzi.io/v1beta2/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL