• Stars
    star
    766
  • Rank 57,299 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 6 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Oh no! Yet another Apache Kafka operator for Kubernetes

Koperator Released License Go version (latest release)


Go version Go Report Card CI Image Image (perf test) Helm chart

Koperator

Koperator is an open-source operator that automates the provisioning, management, and autoscaling of Apache Kafka clusters on Kubernetes. Unlike other solutions that rely on StatefulSets, Koperator has been built with a unique architecture that provides greater flexibility and functionality for managing Apache Kafka. This architecture allows for fine-grained configuration and management of individual brokers.

Some of the main features of Koperator are:

  • the provisioning of secure and production-ready Kafka clusters
  • fine-grained broker-by-broker configuration support
  • advanced and highly configurable external access
  • graceful Kafka cluster scaling and rebalancing
  • detailed Prometheus metrics
  • encrypted communication using SSL
  • automatic reaction and self-healing based on alerts using Cruise Control
  • graceful rolling upgrades
  • advanced topic and user management via Kubernetes Custom Resources
  • Cruise Control task management via Kubernetes Custom Resources

Architecture

Kafka is a stateful application, and the Kafka Broker is a server that can create and form a cluster with other Brokers. Each Broker has its own unique configuration, the most important of which is the unique broker ID.

Most Kubernetes operators that manage Kafka rely on StatefulSets to create a Kafka Cluster. While StatefulSets provide unique Broker IDs generated during Pod startup, networking between brokers with headless services, and unique Persistent Volumes for Brokers, they have a few restrictions. For example, Broker configurations cannot be modified independently, and a specific Broker cannot be removed from the cluster - a StatefulSet always removes the most recently created Broker. Furthermore, multiple, different Persistent Volumes cannot be used for each Broker.

Koperator takes a different approach by using simple Pods, ConfigMaps, and PersistentVolumeClaims instead of StatefulSets. These resources allow us to build an Operator that is better suited to manage Apache Kafka. With Koperator, you can modify the configuration of unique Brokers, remove specific Brokers from clusters, and use multiple Persistent Volumes for each Broker.

If you want to learn more about our design motivations and the scenarios that drove us to create Koperator, please continue reading on our documentation page here.

Koperator architecture

Quick start

This quick start guide will walk you through the process of deploying Koperator on an existing Kubernetes cluster and provisioning a Kafka cluster using its custom resources.

Prerequisites

To complete this guide, you will need a Kubernetes cluster (with a suggested minimum of 6 vCPUs and 8 GB RAM). You can run the cluster locally using Kind or Minikube.

The quick start will help you set up a functioning Kafka cluster on Kubernetes. However, it does not include guidance on the installation of Prometheus and cert-manager, which are necessary for some of the more advanced functionality.

Install ZooKeeper

The version of Kafka that is installed by the operator requires Apache ZooKeeper. You'll need to deploy a ZooKeeper cluster if you donโ€™t already have one.

  1. Install ZooKeeper using Pravegaโ€™s Zookeeper Operator.
helm install zookeeper-operator --repo https://charts.pravega.io zookeeper-operator --namespace=zookeeper --create-namespace
  1. Create a ZooKeeper cluster.
kubectl create -f - <<EOF
apiVersion: zookeeper.pravega.io/v1beta1
kind: ZookeeperCluster
metadata:
    name: zookeeper
    namespace: zookeeper
spec:
    replicas: 1
    persistence:
        reclaimPolicy: Delete
EOF
  1. Verify that ZooKeeper has been deployed.
> kubectl get pods -n zookeeper

NAME                                  READY   STATUS    RESTARTS   AGE
zookeeper-0                           1/1     Running   0          27m
zookeeper-operator-54444dbd9d-2tccj   1/1     Running   0          28m

Install Koperator

You can deploy Koperator using a Helm chart. Complete the following steps.

  1. Install the Koperator CustomResourceDefinition resources (adjust the version number to the Koperator release you want to install). This is performed in a separate step to allow you to uninstall and reinstall Koperator without deleting your already installed custom resources.
kubectl create --validate=false -f https://github.com/banzaicloud/koperator/releases/download/v0.24.1/kafka-operator.crds.yaml
  1. Install Koperator into the kafka namespace:
helm install kafka-operator --repo https://kubernetes-charts.banzaicloud.com kafka-operator --namespace=kafka --create-namespace
  1. Create the Kafka cluster using the KafkaCluster custom resource. The quick start uses a minimal custom resource, but there are other examples in the same directory.
kubectl create -n kafka -f https://raw.githubusercontent.com/banzaicloud/koperator/master/config/samples/simplekafkacluster.yaml
  1. Verify that the Kafka cluster has been created.
> kubectl get pods -n kafka

kafka-0-nvx8c                             1/1     Running   0          16m
kafka-1-swps9                             1/1     Running   0          15m
kafka-2-lppzr                             1/1     Running   0          15m
kafka-cruisecontrol-fb659b84b-7cwpn       1/1     Running   0          15m
kafka-operator-operator-8bb75c7fb-7w4lh   2/2     Running   0          17m

Test Kafka cluster

To test the Kafka cluster let's create a topic and send some messages.

  1. You can use the KafkaTopic CR to create a topic called my-topic:
kubectl create -n kafka -f - <<EOF
apiVersion: kafka.banzaicloud.io/v1alpha1
kind: KafkaTopic
metadata:
    name: my-topic
spec:
    clusterRef:
        name: kafka
    name: my-topic
    partitions: 1
    replicationFactor: 1
    config:
        "retention.ms": "604800000"
        "cleanup.policy": "delete"
EOF
  1. If SSL encryption is disabled for Kafka, you can use the following commands to send and receive messages within a Kubernetes cluster.

To send messages, run this command and type your test messages:

kubectl -n kafka run kafka-producer -it --image=ghcr.io/banzaicloud/kafka:2.13-3.1.0 --rm=true --restart=Never -- /opt/kafka/bin/kafka-console-producer.sh --bootstrap-server kafka-headless:29092 --topic my-topic

To receive messages, run the following command:

kubectl -n kafka run kafka-consumer -it --image=ghcr.io/banzaicloud/kafka:2.13-3.1.0 --rm=true --restart=Never -- /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server kafka-headless:29092 --topic my-topic --from-beginning

Documentation

For detailed documentation on the Koperator project, please visit the Cisco Calisti documentation.

Issues and contributions

We use GitHub to track issues and accept contributions. If you would like to raise an issue or open a pull request, please refer to our contribution guide.

If you use Koperator in a production environment, we encourage you to add yourself to the list of production adopters.

Community

Find us on Slack for more fun about Kafka on Kubernetes!

License

Copyright (c) 2023 Cisco Systems, Inc. and/or its affiliates

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Trademarks

Apache Kafka, Kafka, and the Kafka logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.

More Repositories

1

bank-vaults

A Vault swiss-army knife: a K8s operator, Go client with automatic token renewal, automatic configuration, multiple unseal options and more. A CLI tool to init, unseal and configure Vault (auth methods, secret engines). Direct secret injection into Pods.
Go
1,864
star
2

pipeline

Banzai Cloud Pipeline is a solution-oriented application platform which allows enterprises to develop, deploy and securely scale container-based applications in multi- and hybrid-cloud environments.
Go
1,491
star
3

logging-operator

Logging operator for Kubernetes based on Fluentd and Fluentbit
Go
1,027
star
4

istio-operator

An operator that manages Istio deployments on Kubernetes
Go
534
star
5

banzai-charts

Curated list of Banzai Cloud Helm charts used by the Pipeline Platform
Mustache
366
star
6

thanos-operator

Kubernetes operator for deploying Thanos
Go
278
star
7

pke

PKE is an extremely simple CNCF certified Kubernetes installer and distribution, designed to work on any cloud, VM or bare metal.
Go
263
star
8

hpa-operator

Horizontal Pod Autoscaler operator for Kubernetes. Annotate and let the HPA operator do the rest.
Go
239
star
9

dast-operator

Dynamic Application and API Security Testing
Go
186
star
10

spark-metrics

Spark metrics related custom classes and sinks (e.g. Prometheus)
Scala
172
star
11

cloudinfo

Cloud instance type and price information as a service
Go
164
star
12

telescopes

Telescopes is a cloud instance types and full cluster layout recommender consisting of on-demand and spot/preemptible AWS EC2, Google, Azure, Oracle and Alibaba cloud instances.
Go
162
star
13

hollowtrees

A ruleset based watchguard to keep spot/preemptible instance based clusters safe, with plugins for VMs, Kubernetes, Prometheus and Pipeline
Go
155
star
14

kurun

Run main.go in Kubernetes with one command, also port-forward your app into Kubernetes
Go
132
star
15

jwt-to-rbac

JWT-to-RBAC lets you automatically generate RBAC resources based on JWT tokens
Go
112
star
16

service-tools

Prepare your Node.js application for production
TypeScript
100
star
17

nodepool-labels-operator

Nodepool Labels operator for Kubernetes
Go
69
star
18

drone-kaniko

A thin shim-wrapper around the official Google Kaniko Docker image to make it behave like the Drone Docker plugin.
Shell
56
star
19

pvc-operator

Go
51
star
20

satellite

Determine your cloud provider with a simple HTTP call
Go
49
star
21

prometheus-jmx-exporter-operator

Go
45
star
22

chartsec

Helm Chart security scanner
Go
45
star
23

anchore-image-validator

Anchore Image Validator lets you automatically detect or block security issues just before a Kubernetes pod starts.
Go
44
star
24

spot-price-exporter

Prometheus exporter to track spot price history
Go
40
star
25

logrus-runtime-formatter

Golang runtime package based automatic function, line and package fields for Logrus
Go
40
star
26

kubeconfiger

Example tool for cleaning up untrusted kubeconfig files
Go
36
star
27

spot-termination-exporter

Prometheus spot instance exporter to monitor AWS instance termination with Hollowtrees
Go
36
star
28

imps

ImagePullSecrets controller allows you to distribute image pull secrets based on namespace/pod matches.
Go
30
star
29

banzai-cli

CLI for Banzai Cloud Pipeline platform
Go
30
star
30

allspark

AllSpark is a simple building block for quickly building web microservice deployments for demo purposes.
Go
26
star
31

istio-client-go

Golang API representation for Istio resources
Go
23
star
32

istio-external-demo

Working example for restricting access to external services from an Istio service mesh
23
star
33

k8s-cncf-meetup

Kubernetes and Cloud Native Computing Meetup slides
DIGITAL Command Language
19
star
34

spot-config-webhook

A Kubernetes mutating admission webhook that sets the scheduler of specific pods based on a ConfigMap.
Go
19
star
35

aws-billing-alarm

Shell
15
star
36

aws-autoscaling-exporter

Prometheus exporter with AWS auto scaling group and instance level metrics for Hollowtrees
Go
14
star
37

docker-cruise-control

Linkedin's Cruise Control container image built for Koperator (https://github.com/banzaicloud/koperator)
Shell
13
star
38

lambda-slack-bot

AWS Lambda Golang Slack bot to list running EC2 instances
Go
12
star
39

fluent-plugin-label-router

Fluentd plugin to route records based on Kubernetes labels and namespace
Ruby
11
star
40

docker-kafka

Dockerfile to building Docker image for Apache Kafka
Dockerfile
10
star
41

crd-updater

Helm 3 library chart that emulates Helm 2 CRD update behavior.
Go
10
star
42

ht-k8s-action-plugin

Hollowtrees plugin used to interact with Kubernetes on specific event triggers
Go
10
star
43

preemption-exporter

Prometheus preemptible instance exporter to monitor GCP instance termination with Hollowtrees
Go
10
star
44

jmx-exporter-loader

Java
10
star
45

go-code-generation-demo

Go
9
star
46

bank-vaults-workshop

Material for the Hacktivity 2019 - Bank-Vaults workshop
7
star
47

pipeline-cp-launcher

Pipeline ControlPlane launcher using AWS Cloudformation or Azure ARM template, running on Kubernetes
Makefile
7
star
48

zeppelin-pdi-example

6
star
49

go-cruise-control

It's client library written in Golang for interacting with Linkedin Cruise Control using its HTTP API.
Go
5
star
50

bank-vaults-docs

Bank-Vaults documentation
Shell
5
star
51

logging-operator-docs

Logging operator documentation
Shell
4
star
52

banzai-types

Common types, configs and utils used across several Banzai Cloud projects
Go
4
star
53

koperator-docs

Documentation for Koperator - the operator for managing Apache Kafka on Kubernetes
HTML
4
star
54

circleci-orbs

Makefile
3
star
55

ht-aws-asg-action-plugin

Hollowtrees plugin to detach instances from auto scaling groups
Go
3
star
56

drone-plugin-sonar

Drone plugin for static code analysis
Go
3
star
57

fluent-plugin-tag-normaliser

Fluent output plugin to transform tags based on record content
Ruby
2
star
58

cicd-go

A Go client for the Pipeline CI/CD subsystem
Go
2
star
59

gin-utilz

Gin framework utilities
Go
2
star
60

banzailint

Custom lint rules for Banzai Cloud code
Makefile
2
star
61

docker-jmx-exporter

Docker image for JMX-exporter
Dockerfile
2
star
62

.github

Github default files
1
star
63

cadence-aws-sdk

Cadence wrapper around the AWS Go SDK to make working with the AWS API easier in Cadence workflows
Go
1
star
64

developer-guide

Guide for developers on writing code and maintaining projects
1
star
65

thanos-operator-docs

Thanos operator documentation
Shell
1
star
66

drone-plugin-k8s-client

Drone plugin implementation for k8s operations
Go
1
star
67

dynamic-class-gen

Java
1
star
68

custom-runner

go custom runner
Go
1
star
69

cluster-registry

Go
1
star
70

integrated-service-sdk

Client SDK for the Integrated Service Operator
Go
1
star
71

log-socket

Service and CLI tool for forwarding logs through a WebSocket connection
Go
1
star
72

kube-service-annotate

A Kubernetes mutating webhook to annotate services based on rules
Go
1
star
73

pipeline-sdk

SDK for extending Pipeline
Go
1
star
74

pipeline-cp-images

Pipeline ControlPlane images
Shell
1
star
75

dockerized-newman

Automated end-2-end testing with Postman in Docker
1
star
76

drone-plugin-zeppelin-client

Zeppelin REST API client plugin for Drone. A step in the Pipeline PaaS CI/CD component to provision a Kubernetes cluster or use a managed one
Go
1
star