Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Changed

- Getting started guide uses a KRaft cluster instead of ZooKeeper and declares its topic with a
KafkaTopic managed by the agent ([#1079]).

[#1079]: https://github.com/stackabletech/kafka-operator/pull/1079

## [26.11.0] - 2026-11-20

### Fixed
Expand Down
105 changes: 58 additions & 47 deletions docs/modules/kafka/examples/getting_started/getting_started.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ echo "Installing Operators with Helm"
helm install --wait commons-operator oci://oci.stackable.tech/sdp-charts/commons-operator --version 0.0.0-dev
helm install --wait secret-operator oci://oci.stackable.tech/sdp-charts/secret-operator --version 0.0.0-dev
helm install --wait listener-operator oci://oci.stackable.tech/sdp-charts/listener-operator --version 0.0.0-dev
helm install --wait zookeeper-operator oci://oci.stackable.tech/sdp-charts/zookeeper-operator --version 0.0.0-dev
helm install --wait kafka-operator oci://oci.stackable.tech/sdp-charts/kafka-operator --version 0.0.0-dev
# end::helm-install-operators[]
;;
Expand All @@ -43,7 +42,6 @@ stackablectl operator install \
commons=0.0.0-dev \
secret=0.0.0-dev \
listener=0.0.0-dev \
zookeeper=0.0.0-dev \
kafka=0.0.0-dev
# end::stackablectl-install-operators[]
;;
Expand All @@ -53,23 +51,6 @@ exit 1
;;
esac

echo "Installing ZooKeeper from zookeeper.yaml"
# tag::install-zookeeper[]
kubectl apply -f zookeeper.yaml
# end::install-zookeeper[]

echo "Installing ZNode from kafka-znode.yaml"
# tag::install-znode[]
kubectl apply -f kafka-znode.yaml
# end::install-znode[]

sleep 15

echo "Awaiting ZooKeeper rollout finish"
# tag::watch-zookeeper-rollout[]
kubectl rollout status --watch --timeout=5m statefulset/simple-zk-server-default
# end::watch-zookeeper-rollout[]

echo "Install KafkaCluster from kafka.yaml"
# tag::install-kafka[]
kubectl apply --server-side -f kafka.yaml
Expand All @@ -79,47 +60,77 @@ sleep 15

echo "Awaiting Kafka rollout finish"
# tag::watch-kafka-rollout[]
kubectl rollout status --watch --timeout=5m statefulset/simple-kafka-controller-default
kubectl rollout status --watch --timeout=5m statefulset/simple-kafka-broker-default
# end::watch-kafka-rollout[]

echo "Starting port-forwarding of port 9092"
# shellcheck disable=2069 # we want all output to be blackholed
# tag::port-forwarding[]
kubectl port-forward svc/simple-kafka-broker-default-bootstrap 9092 2>&1 >/dev/null &
# end::port-forwarding[]
PORT_FORWARD_PID=$!
# shellcheck disable=2064 # we want the PID evaluated now, not at the time the trap is
trap "kill $PORT_FORWARD_PID" EXIT

sleep 15
echo "Awaiting the Kafka agent"
# tag::watch-agent-rollout[]
kubectl rollout status --watch --timeout=5m deployment/simple-kafka-agent
# end::watch-agent-rollout[]

echo "Creating test topic test-data-topic"
echo "Creating test topic test-data-topic from kafka-topic.yaml"
# tag::create-topic[]
kubectl exec -n default simple-kafka-broker-default-0 -c kafka -t -- /stackable/kafka/bin/kafka-topics.sh \
--create \
--topic test-data-topic \
--partitions 1 \
--bootstrap-server localhost:9092
kubectl apply -f kafka-topic.yaml
# end::create-topic[]

echo "Awaiting the KafkaTopic"
# tag::wait-topic[]
kubectl wait --for=condition=Ready --timeout=5m kafkatopics.kafka.stackable.tech/test-data-topic
# end::wait-topic[]

echo "Publish test data"
# shellcheck disable=SC2016 # the script is expanded in the broker Pod, not here
# Capture the output of the producer and only show it if sending failed.
produced="$(
{
# tag::write-data[]
kubectl exec -n default simple-kafka-broker-default-0 -c kafka -t -- /stackable/kafka/bin/kafka-producer-perf-test.sh \
--producer-props bootstrap.servers=localhost:9092 \
--topic test-data-topic \
--payload-monotonic \
--throughput 1 \
--num-records 5
kubectl exec -n default simple-kafka-broker-default-0 -c kafka -- bash -c '
bootstrap="$(cat /stackable/listener-broker/default-address/address):$(cat /stackable/listener-broker/default-address/ports/kafka-tls)"
/stackable/kafka/bin/kafka-producer-perf-test.sh \
--producer-props bootstrap.servers="$bootstrap" \
--producer.config /stackable/config/client.properties \
--topic test-data-topic \
--payload-monotonic \
--throughput 1 \
--num-records 5
'
# end::write-data[]
} 2>&1
)"

if ! grep -q '^5 records sent,' <<< "$produced"; then
echo "ERROR: expected 5 records to be sent, producer output:" >&2
echo "$produced" >&2
exit 1
fi

echo "Consume test data"
# shellcheck disable=SC2016 # the script is expanded in the broker Pod, not here
# The consumer exits with 0 even if it times out without reading anything,
# so capture its output and verify the summary line explicitly below.
consumed="$(
{
# tag::read-data[]
kubectl exec -n default simple-kafka-broker-default-0 -c kafka -t -- /stackable/kafka/bin/kafka-console-consumer.sh \
--bootstrap-server localhost:9092 \
--topic test-data-topic \
--offset earliest \
--partition 0 \
--timeout-ms 1000
kubectl exec -n default simple-kafka-broker-default-0 -c kafka -- bash -c '
bootstrap="$(cat /stackable/listener-broker/default-address/address):$(cat /stackable/listener-broker/default-address/ports/kafka-tls)"
/stackable/kafka/bin/kafka-console-consumer.sh \
--bootstrap-server "$bootstrap" \
--consumer.config /stackable/config/client.properties \
--topic test-data-topic \
--offset earliest \
--partition 0 \
--max-messages 5 \
--timeout-ms 30000
'
# end::read-data[]
} 2>&1
)"

if ! grep -qx 'Processed a total of 5 messages' <<< "$consumed"; then
echo "ERROR: expected 5 consumed messages, consumer output:" >&2
echo "$consumed" >&2
exit 1
fi

echo "Success!"
105 changes: 58 additions & 47 deletions docs/modules/kafka/examples/getting_started/getting_started.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ echo "Installing Operators with Helm"
helm install --wait commons-operator oci://{{ helm.repo_url }}/{{ helm.repo_name }}/commons-operator --version {{ versions.commons }}
helm install --wait secret-operator oci://{{ helm.repo_url }}/{{ helm.repo_name }}/secret-operator --version {{ versions.secret }}
helm install --wait listener-operator oci://{{ helm.repo_url }}/{{ helm.repo_name }}/listener-operator --version {{ versions.listener }}
helm install --wait zookeeper-operator oci://{{ helm.repo_url }}/{{ helm.repo_name }}/zookeeper-operator --version {{ versions.zookeeper }}
helm install --wait kafka-operator oci://{{ helm.repo_url }}/{{ helm.repo_name }}/kafka-operator --version {{ versions.kafka }}
# end::helm-install-operators[]
;;
Expand All @@ -43,7 +42,6 @@ stackablectl operator install \
commons={{ versions.commons }} \
secret={{ versions.secret }} \
listener={{ versions.listener }} \
zookeeper={{ versions.zookeeper }} \
kafka={{ versions.kafka }}
# end::stackablectl-install-operators[]
;;
Expand All @@ -53,23 +51,6 @@ exit 1
;;
esac

echo "Installing ZooKeeper from zookeeper.yaml"
# tag::install-zookeeper[]
kubectl apply -f zookeeper.yaml
# end::install-zookeeper[]

echo "Installing ZNode from kafka-znode.yaml"
# tag::install-znode[]
kubectl apply -f kafka-znode.yaml
# end::install-znode[]

sleep 15

echo "Awaiting ZooKeeper rollout finish"
# tag::watch-zookeeper-rollout[]
kubectl rollout status --watch --timeout=5m statefulset/simple-zk-server-default
# end::watch-zookeeper-rollout[]

echo "Install KafkaCluster from kafka.yaml"
# tag::install-kafka[]
kubectl apply --server-side -f kafka.yaml
Expand All @@ -79,47 +60,77 @@ sleep 15

echo "Awaiting Kafka rollout finish"
# tag::watch-kafka-rollout[]
kubectl rollout status --watch --timeout=5m statefulset/simple-kafka-controller-default
kubectl rollout status --watch --timeout=5m statefulset/simple-kafka-broker-default
# end::watch-kafka-rollout[]

echo "Starting port-forwarding of port 9092"
# shellcheck disable=2069 # we want all output to be blackholed
# tag::port-forwarding[]
kubectl port-forward svc/simple-kafka-broker-default-bootstrap 9092 2>&1 >/dev/null &
# end::port-forwarding[]
PORT_FORWARD_PID=$!
# shellcheck disable=2064 # we want the PID evaluated now, not at the time the trap is
trap "kill $PORT_FORWARD_PID" EXIT

sleep 15
echo "Awaiting the Kafka agent"
# tag::watch-agent-rollout[]
kubectl rollout status --watch --timeout=5m deployment/simple-kafka-agent
# end::watch-agent-rollout[]

echo "Creating test topic test-data-topic"
echo "Creating test topic test-data-topic from kafka-topic.yaml"
# tag::create-topic[]
kubectl exec -n default simple-kafka-broker-default-0 -c kafka -t -- /stackable/kafka/bin/kafka-topics.sh \
--create \
--topic test-data-topic \
--partitions 1 \
--bootstrap-server localhost:9092
kubectl apply -f kafka-topic.yaml
# end::create-topic[]

echo "Awaiting the KafkaTopic"
# tag::wait-topic[]
kubectl wait --for=condition=Ready --timeout=5m kafkatopics.kafka.stackable.tech/test-data-topic
# end::wait-topic[]

echo "Publish test data"
# shellcheck disable=SC2016 # the script is expanded in the broker Pod, not here
# Capture the output of the producer and only show it if sending failed.
produced="$(
{
# tag::write-data[]
kubectl exec -n default simple-kafka-broker-default-0 -c kafka -t -- /stackable/kafka/bin/kafka-producer-perf-test.sh \
--producer-props bootstrap.servers=localhost:9092 \
--topic test-data-topic \
--payload-monotonic \
--throughput 1 \
--num-records 5
kubectl exec -n default simple-kafka-broker-default-0 -c kafka -- bash -c '
bootstrap="$(cat /stackable/listener-broker/default-address/address):$(cat /stackable/listener-broker/default-address/ports/kafka-tls)"
/stackable/kafka/bin/kafka-producer-perf-test.sh \
--producer-props bootstrap.servers="$bootstrap" \
--producer.config /stackable/config/client.properties \
--topic test-data-topic \
--payload-monotonic \
--throughput 1 \
--num-records 5
'
# end::write-data[]
} 2>&1
)"

if ! grep -q '^5 records sent,' <<< "$produced"; then
echo "ERROR: expected 5 records to be sent, producer output:" >&2
echo "$produced" >&2
exit 1
fi

echo "Consume test data"
# shellcheck disable=SC2016 # the script is expanded in the broker Pod, not here
# The consumer exits with 0 even if it times out without reading anything,
# so capture its output and verify the summary line explicitly below.
consumed="$(
{
# tag::read-data[]
kubectl exec -n default simple-kafka-broker-default-0 -c kafka -t -- /stackable/kafka/bin/kafka-console-consumer.sh \
--bootstrap-server localhost:9092 \
--topic test-data-topic \
--offset earliest \
--partition 0 \
--timeout-ms 1000
kubectl exec -n default simple-kafka-broker-default-0 -c kafka -- bash -c '
bootstrap="$(cat /stackable/listener-broker/default-address/address):$(cat /stackable/listener-broker/default-address/ports/kafka-tls)"
/stackable/kafka/bin/kafka-console-consumer.sh \
--bootstrap-server "$bootstrap" \
--consumer.config /stackable/config/client.properties \
--topic test-data-topic \
--offset earliest \
--partition 0 \
--max-messages 5 \
--timeout-ms 30000
'
# end::read-data[]
} 2>&1
)"

if ! grep -qx 'Processed a total of 5 messages' <<< "$consumed"; then
echo "ERROR: expected 5 consumed messages, consumer output:" >&2
echo "$consumed" >&2
exit 1
fi

echo "Success!"
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Installed commons=0.0.0-dev operator
Installed secret=0.0.0-dev operator
Installed listener=0.0.0-dev operator
Installed zookeeper=0.0.0-dev operator
Installed kafka=0.0.0-dev operator
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Installed commons={{ versions.commons }} operator
Installed secret={{ versions.secret }} operator
Installed listener={{ versions.listener }} operator
Installed zookeeper={{ versions.zookeeper }} operator
Installed kafka={{ versions.kafka }} operator
10 changes: 10 additions & 0 deletions docs/modules/kafka/examples/getting_started/kafka-topic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: kafka.stackable.tech/v1alpha1
kind: KafkaTopic
metadata:
name: test-data-topic
spec:
clusterRef:
name: simple-kafka
partitions: 1
replicationFactor: 3
8 changes: 0 additions & 8 deletions docs/modules/kafka/examples/getting_started/kafka-znode.yaml

This file was deleted.

15 changes: 11 additions & 4 deletions docs/modules/kafka/examples/getting_started/kafka.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ metadata:
name: simple-kafka
spec:
image:
productVersion: 3.9.2
productVersion: 4.3.1
clusterConfig:
tls:
serverSecretClass: null
zookeeperConfigMapName: simple-kafka-znode
metadataManager: KRaft
managementAccess: # Deploys the agent, which creates and updates KafkaTopics in this cluster
enabled: true
authentication:
userProvided:
anonymous: {}
controllers:
roleGroups:
default:
replicas: 1
brokers:
config:
bootstrapListenerClass: external-unstable # This exposes your Stacklet outside of Kubernetes. Remove this property if this is not desired
Expand Down
12 changes: 0 additions & 12 deletions docs/modules/kafka/examples/getting_started/zookeeper.yaml

This file was deleted.

Loading