Cqlsh in a container
Some reasons why you might be interested:
- Run
cqlfiles to load data tocassandrawhen it starts - Execute remote commands without
execdirectly tocassandra
The default CMD command in the image will try to connect to cassandra using default env vars
and execute each .cql file found in the container /scripts path.
In order to run this container you'll need docker installed.
$ docker run -it nuvo/docker-cqlsh bashCQLVERSION- The native transport version to use (default:3.4.4)CQLSH_HOST- Cassandra host (default:cassandra)CQLSH_PORT- Cassandra port (default:9042)
Standalone instance
Run a cassandra container and connect to it
$ docker run -d -p 9042:9042 cassandra
$ docker run --rm -it -e CQLSH_HOST=localhost --net=host nuvo/docker-cqlsh bash
bash-4.4$ cqlsh -e "show host;"
Connected to Test Cluster at localhost:9042.Kubernetes job
apiVersion: batch/v1
king: Job
metadata:
name: load-cql-files
spec:
backoffLimit: 5
activeDeadlineSeconds: 100
template:
spec:
containers:
- name: cqlsh
image: nuvo/docker-cqlsh
env:
- name: CQLSH_HOST
value: cassandra-svc
volumeMounts:
- mountPath: /scripts
name: scripts
volumes:
- name: scripts
configMap:
name: cql-filesThis project is licensed under the Apache 2.0 License - see the LICENSE file for details.
cqlsh is a Python-based command-line tool, and the most direct way to run simple CQL commands on a Cassandra cluster. This is a simple re-bundling of the open source tool that comes bundled with Cassandra to allow for cqlsh to be installed and run inside of virtual environments (source)