Skip to main content

Run Krabka on Kubernetes

Install the operator and a three-node broker cluster, then send and read your first record. This configuration is for evaluation, not a production deployment.

Before you start

  • Use a Bash terminal. On Windows, use a Bash terminal that can run kubectl and helm.
  • Use a disposable Kubernetes cluster with kubectl and Helm 3 configured.
  • Make sure that the cluster has capacity for three broker pods.
  • Make sure that the cluster has a default storage class for the three 1 GiB persistent volumes.
  • Confirm that kubectl config current-context selects this disposable cluster.
  • Use the default namespace in your context. The brokers use default, and the operator uses krabka-system.
  • Use a cluster without another installation of these CRDs.

This example runs krabka-operator 1.0.2 and krabka-broker 1.0.8.

1. Install the operator

kubectl apply -f https://krabka.io/quickstart/crds.yaml
helm repo add krabka https://krabka.io/charts
helm repo update
helm install krabka-operator krabka/krabka-operator --version 1.0.2 --skip-crds \
  --namespace krabka-system --create-namespace
kubectl rollout status deployment/krabka-operator-krabka-operator -n krabka-system --timeout=5m

2. Create the cluster and wait for readiness

kubectl apply -f https://krabka.io/quickstart/krabka-cluster.yaml
kubectl wait --for=condition=Ready kafka/m20-quickstart --timeout=10m
kubectl wait --for=condition=Ready kafkatopic/quickstart --timeout=5m

If readiness fails, inspect kubectl get pods -n default, kubectl get pvc -n default, and kubectl logs deployment/krabka-operator-krabka-operator -n krabka-system. Resolve image-pull, storage, or scheduling errors before continuing.

3. Produce and consume a record

Continue when both kubectl wait commands report that the Ready condition is met. The manifest creates the quickstart topic. Run Kafka tools inside the cluster because brokers advertise in-cluster names.

KAFKA_TOOLS=docker.io/apache/kafka@sha256:01b9a4030e54c6068e66eb3ba4cb82c0d89238629ef1c30d79b86036bf89b1b7
kubectl run kafka-tools --image="$KAFKA_TOOLS" --restart=Never --rm -i --command -- \
  /bin/bash -lc "$(cat <<'KAFKA_VERIFY'
printf 'hello krabka\n' | /opt/kafka/bin/kafka-console-producer.sh \
  --bootstrap-server m20-quickstart-broker-headless.default.svc.cluster.local:9092 \
  --topic quickstart &&
/opt/kafka/bin/kafka-console-consumer.sh \
  --bootstrap-server m20-quickstart-broker-headless.default.svc.cluster.local:9092 \
  --topic quickstart --from-beginning --max-messages 1 --timeout-ms 30000
KAFKA_VERIFY
)"

The consumer prints hello krabka. See Configure the operator to change this deployment.

4. Inspect the cluster with Kafka admin tools

Run these tools inside the cluster. The bootstrap address uses the broker service in the default namespace; a port-forward alone does not make advertised in-cluster broker names reachable from your host.

KAFKA_TOOLS=docker.io/apache/kafka@sha256:01b9a4030e54c6068e66eb3ba4cb82c0d89238629ef1c30d79b86036bf89b1b7
kubectl run "kafka-inspect-$RANDOM" -n default --image="$KAFKA_TOOLS" \
  --restart=Never --rm -i --pod-running-timeout=120s \
  --overrides='{"spec":{"activeDeadlineSeconds":240}}' --command -- \
  /bin/bash -seuo pipefail <<'KAFKA_INSPECT'
    BOOTSTRAP=m20-quickstart-broker-headless.default.svc.cluster.local:9092
    echo "[topic]"
    timeout 45s /opt/kafka/bin/kafka-topics.sh --bootstrap-server "$BOOTSTRAP" --describe --topic quickstart
    echo "[quorum]"
    timeout 45s /opt/kafka/bin/kafka-metadata-quorum.sh --bootstrap-server "$BOOTSTRAP" describe --status
    echo "[groups]"
    timeout 45s /opt/kafka/bin/kafka-consumer-groups.sh --bootstrap-server "$BOOTSTRAP" --list
    echo "[api]"
    timeout 45s /opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server "$BOOTSTRAP"
KAFKA_INSPECT

The topic description shows quickstart with one partition and one replica. The quorum status reports a leader ID and the current voters. The consumer-group list can be empty; a successful empty result is valid. The API output lists broker IDs and supported version ranges. See the compatibility matrix for supported Kafka APIs.

Each tool has a 45-second limit. The command stops if a tool fails, and the inspection pod has a four-minute deadline. If a command fails, check cluster readiness and DNS before repeating it. Each run uses a new pod name, separate from the round-trip pod.

Clean up the Kubernetes example

Cleanup is optional. These commands remove the example cluster, topic, operator, and Krabka CRDs. Deleting CRDs affects every resource of those types. Run this only in the disposable cluster used for this example. Check your storage policy before removing persistent volumes.

kubectl delete kafkatopic/quickstart
kubectl delete kafka/m20-quickstart
kubectl delete kafkanodepool/brokers --ignore-not-found
helm uninstall krabka-operator -n krabka-system
kubectl delete -f https://krabka.io/quickstart/crds.yaml

Review the operations guides before deploying your own cluster.

Choose your next task