3

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!

Robert
  • 348
  • 3
  • 11

3 Answers3

1

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
Robin Moffatt
  • 30,382
  • 3
  • 65
  • 92
  • Thanks @robin-moffatt. Unfortunately I am indeed now solving networking issues. The Kafka cluster isn't directly accessible, so in my WSL 2 command line I'm port-forwarding the Kubernetes ksqlDB server port 8088, and trying to connect to that from within Docker (which isn't working yet). This is why I wanted to simply install the ksqlDB CLI tool in my Linux environment and connect directly. – Robert Nov 12 '20 at 17:17
  • OK understand. Yeah that does sound fiddly. Have you tried `host.docker.internal` to access your local machine from the docker container? – Robin Moffatt Nov 12 '20 at 17:48
  • Thanks for checking back! :-) I did, but there was some error connecting to the Kubernetes port-forward. – Robert Nov 19 '20 at 18:21
0

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).

Robert
  • 348
  • 3
  • 11
0

Credit: https://luppeng.wordpress.com/2022/11/20/access-ksqldb-cli-inside-a-browser-using-ttyd/

This worked for me to connect to a ksqldb server running inside the docker instance as per the quick start:

For version 0.28.2 (change as needed):

  1. Installation:
    curl http://ksqldb-packages.s3.amazonaws.com/archive/0.28/confluent-ksqldb-0.28.2.tar.gz --output confluent-ksqldb-0.28.2.tar.gz
    tar -xzf confluent-ksqldb-0.28.2.tar.gz
    
  2. Run (change address as needed):
    confluent-ksqldb-0.28.2/bin/ksql http://myksqldbhost:8088
    
Feso
  • 41
  • 4