How do I install just the ksqlDB CLI tool on Linux?

Viewed 2021

This seems like something that should be so simple! (Every other CLI tool I use has an easy install process.)

We're running ksqlDB in a Kubernetes cluster, and I would like to connect to it with the CLI from my local machine (either Windows 10 or from WSL 2)

Is this simply not possible?

Thanks!

2 Answers

The simplest by far is indeed to use the Docker image. From the container, you can connect to your ksqlDB server the same as you would from your host machine.

docker run --interactive --tty --rm confluentinc/ksqldb-cli:0.12.0 \
       ksql https://my-ksqldb-server.foo.corp

Or if you have auth setup (e.g. if you were using Confluent Cloud):

docker run --interactive --tty --rm confluentinc/ksqldb-cli:0.12.0 \
       ksql --user myKsqlDBUser$KSQLDB_API_KEY \
            --password Admin123 \
            https://my-ksqldb-server.foo.corp

Alright - he's how I was successfully able to connect. I never did - unfortunately - find a way to easily install just the ksql CLI tool locally.

Nor did not end up using the local ksql-cli docker image with a Kubernetes port-forward to the cluster due to Docker networking issues.

Instead, I shelled directly into the Kubernetes ksqlDB server. This tripped me up a bit because we're using the cp-kafka helm chart, and the ksqlDB pod runs two containers - so you have to ensure you're shelling into the correct container (and without specifying the container, you won't).

Here's the command I used:

kubectl -n kafka --stdin --tty name-of-ksql-server-pod -c cp-ksql-server --/bin/bash

-n kafka - using the kafka Kubernetes namespace

--stdin --tty - ensures I can shell in correctly

-c cp-ksql-server - the ksql server container within the pod. I got this name by doing a kubectl -n kafka describe pod name-of-ksql-server-pod and then looking through the resulting list of containers.

Then a simple ksql at the command line was enough to successfully connect (without any localhost or anything).

Related