# Temporalio/admin-tools using docker to create cassandra schema

**URL:** <https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352>\
**Category:** Community Support\
**Created:** [August 3, 2020, 6:40pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352 "2020-08-03T18:40:43Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![kasi](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kasi](https://community.temporal.io/u/kasi)\
**Post date:** [August 3, 2020, 6:40pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/1 "2020-08-03T18:40:43Z")

</div>

Hi,

I am trying to use temporalio/admin-tools to create schema in cassandra, can you please let me know how I can do it, what is the docker command I need to use?

Thanks,  
Kasi

---

<div class="post-metadata">

**Author:** ![markmark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/markmark/32/88_2.png) [@markmark](https://community.temporal.io/u/markmark)\
**Post date:** [August 3, 2020, 7:12pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/2 "2020-08-03T19:12:09Z")

</div>

Hi Kasi, thank you for the question!

This section of Temporal Helm Chart README describes using `temporal-cassandra-tool` for initializing Temporal keyspaces in Cassandra.

> **[temporalio/helm-charts](https://github.com/temporalio/helm-charts#bring-your-own-cassandra)**
>
> Helm Chart for deploying Temporal. Contribute to temporalio/helm-charts development by creating an account on GitHub.

And here is a fragment of how our CI/CD pipelines do this, via the `admin-tools` container running in the instance’s kubernetes cluster.

```
     # Setup keyspaces.
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 temporal-cassandra-tool create-Keyspace -k temporal"
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 CASSANDRA_KEYSPACE=temporal temporal-cassandra-tool setup-schema -v 0.0"
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 CASSANDRA_KEYSPACE=temporal ./temporal-cassandra-tool update -schema-dir /etc/temporal/schema/cassandra/temporal/versioned"
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 temporal-cassandra-tool create-Keyspace -k temporal_visibility"
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 CASSANDRA_KEYSPACE=temporal_visibility ./temporal-cassandra-tool setup-schema -v 0.0"
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 CASSANDRA_KEYSPACE=temporal_visibility ./temporal-cassandra-tool update -schema-dir /etc/temporal/schema/cassandra/visibility/versioned"

```

I hope this helps!

Thank you,  
Mark.

---

<div class="post-metadata">

**Author:** ![kasi](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kasi](https://community.temporal.io/u/kasi)\
**Post date:** [August 3, 2020, 7:23pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/3 "2020-08-03T19:23:08Z")

</div>

Thanks mark, ideally I want to run the temporal-cassandra-tool from the admin-tools docker image using docker run --rm command, can you please help?

---

<div class="post-metadata">

**Author:** ![markmark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/markmark/32/88_2.png) [@markmark](https://community.temporal.io/u/markmark)\
**Post date:** [August 3, 2020, 7:35pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/4 "2020-08-03T19:35:03Z")

</div>

Ah! I don’t think we have any automation that does this specific operation, but I think you should be able to craft your `docker run` command line to do this, something along the lines of

```auto
$ docker run -rm -it -e CASSANDRA_HOST="cassandra-h1" -e < ... > --entrypoint /bin/bash temporalio/admin-tools -c temporal-cassandra-tool create-Keyspace -k temporal

```

---

<div class="post-metadata">

**Author:** ![kasi](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kasi](https://community.temporal.io/u/kasi)\
**Post date:** [August 3, 2020, 7:47pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/5 "2020-08-03T19:47:14Z")

</div>

> [@markmark](#):
>
> `docker run -rm -it -e CASSANDRA_HOST="cassandra-h1" -e < ... > --entrypoint /bin/bash temporalio/admin-tools -c temporal-cassandra-tool create-Keyspace -k temporal`

Thanks a ton, will try it out

---

<div class="post-metadata">

**Author:** ![kasi](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kasi](https://community.temporal.io/u/kasi)\
**Post date:** [August 3, 2020, 9:22pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/6 "2020-08-03T21:22:15Z")

</div>

There is a setup schema setup-schema -v 0.0 and update schema with schema directory update-schema -d $SCHEMA\_DIR how do we achieve this?

Thanks,

Kasi

---

<div class="post-metadata">

**Author:** ![markmark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/markmark/32/88_2.png) [@markmark](https://community.temporal.io/u/markmark)\
**Post date:** [August 3, 2020, 9:41pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/7 "2020-08-03T21:41:11Z")

</div>

I might be misreading the question, but if you are looking for the schema files inside of `admin-tool` docker image, see the snippet I included earlier, which includes complete paths (e. g. `/etc/temporal/schema/cassandra/temporal/versioned`).

Example:

```auto
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 CASSANDRA_KEYSPACE=temporal ./temporal-cassandra-tool update -schema-dir /etc/temporal/schema/cassandra/temporal/versioned"

```

---

<div class="post-metadata">

**Author:** ![kasi](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kasi](https://community.temporal.io/u/kasi)\
**Post date:** [August 3, 2020, 9:48pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/8 "2020-08-03T21:48:53Z")

</div>

Thanks Mark, no you did not misread the question, using the docker the way we create the keySpace, we should also be able to create and update schema, the only issue is the update schema which has a schema directory which is dependent on the TEMPORAL\_HOME, in the case of Docker how do we specify the temporal home

---

<div class="post-metadata">

**Author:** ![markmark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/markmark/32/88_2.png) [@markmark](https://community.temporal.io/u/markmark)\
**Post date:** [August 3, 2020, 10:00pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/9 "2020-08-03T22:00:18Z")

</div>

Oh interesting, I didn’t realize our schemas have a dependency on `$TEMPORAL_HOME` env var. How are you running schema setup tools? Maybe I could repro this.

And in any case, I think `admin-tools` already has this env var set to `/etc/temporal`:

```auto
$ docker run -it --entrypoint /bin/bash temporalio/admin-tools -c env | grep TEMPORAL_HOME
TEMPORAL_HOME=/etc/temporal 

```

---

<div class="post-metadata">

**Author:** ![kasi](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kasi](https://community.temporal.io/u/kasi)\
**Post date:** [August 3, 2020, 10:16pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/10 "2020-08-03T22:16:35Z")

</div>

Great!!! will try it out

---

<div class="post-metadata">

**Author:** ![kasi](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kasi](https://community.temporal.io/u/kasi)\
**Post date:** [August 4, 2020, 5:50pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/11 "2020-08-04T17:50:42Z")

</div>

> [@markmark](#):
>
> create-Keyspace -k temporal

Mark, temporal-cassandra-tool is complaining as if no arguments were passed to it

---

<div class="post-metadata">

**Author:** ![markmark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/markmark/32/88_2.png) [@markmark](https://community.temporal.io/u/markmark)\
**Post date:** [August 4, 2020, 9:43pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/12 "2020-08-04T21:43:16Z")

</div>

Hmmm… I wonder if i can reproduce this problem on my machine. Can you paste the command line that you are using, and the error are you seeing?

---

<div class="post-metadata">

**Author:** ![markmark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/markmark/32/88_2.png) [@markmark](https://community.temporal.io/u/markmark)\
**Post date:** [August 4, 2020, 9:54pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/13 "2020-08-04T21:54:52Z")

</div>

PS Also check out the snippet from earlier on this thread – notice how it is supplying environment variables. If those vars are not there, `temporal-cassandra-tool` will fallback on default values when possible, or fail. Make sure your code supplies those params.

```auto
     # Setup keyspaces.
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 temporal-cassandra-tool create-Keyspace -k temporal"
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 CASSANDRA_KEYSPACE=temporal temporal-cassandra-tool setup-schema -v 0.0"
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 CASSANDRA_KEYSPACE=temporal ./temporal-cassandra-tool update -schema-dir /etc/temporal/schema/cassandra/temporal/versioned"
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 temporal-cassandra-tool create-Keyspace -k temporal_visibility"
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 CASSANDRA_KEYSPACE=temporal_visibility ./temporal-cassandra-tool setup-schema -v 0.0"
     kubectl exec -it services/temporaltest-admintools -- bash -c "CASSANDRA_HOST=cassandra.default.svc.cluster.local CASSANDRA_PORT=9042 CASSANDRA_KEYSPACE=temporal_visibility ./temporal-cassandra-tool update -schema-dir /etc/temporal/schema/cassandra/visibility/versioned"

```

---

<div class="post-metadata">

**Author:** ![kasi](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kasi](https://community.temporal.io/u/kasi)\
**Post date:** [August 4, 2020, 9:56pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/14 "2020-08-04T21:56:52Z")

</div>

> [@markmark](#):
>
> create-Keyspace -k temporal

Thanks Mark, I did, also what does the -c option do, cannot find a suitable explanation, I gave all the env params

---

<div class="post-metadata">

**Author:** ![markmark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/markmark/32/88_2.png) [@markmark](https://community.temporal.io/u/markmark)\
**Post date:** [August 4, 2020, 10:00pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/15 "2020-08-04T22:00:27Z")

</div>

ah, `-c` is just a param to bash, indicating that the string that follows is the command that needs to run in bash in the container.

[https://linux.die.net/man/1/bash](https://linux.die.net/man/1/bash)

Not sure what is happening there, but if you give me repro steps, I will try to repro and debug this.

---

<div class="post-metadata">

**Author:** ![kasi](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kasi](https://community.temporal.io/u/kasi)\
**Post date:** [August 5, 2020, 3:25pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/16 "2020-08-05T15:25:20Z")

</div>

Hey Mark,

Thanks a lot, here is the command.

docker run --rm -it -e CASSANDRA\_HOST=“xxxxxxx” -e CASSANDRA\_PORT=9042 -e CASSANDRA\_USER=user1 -e CASSANDRA\_PASSWORD=‘xxxxxx#2020’ --entrypoint /bin/sh [dockerproxy.aexp.com/temporalio/admin-tools:0.26.0](http://dockerproxy.aexp.com/temporalio/admin-tools:0.26.0) -c temporal-cassandra-tool

the output is running the temporal-cassandra-tool with --help command.

Thanks,

Kasi

---

<div class="post-metadata">

**Author:** ![markmark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/markmark/32/88_2.png) [@markmark](https://community.temporal.io/u/markmark)\
**Post date:** [August 5, 2020, 4:06pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/17 "2020-08-05T16:06:46Z")

</div>

Thank you Kasi.

I am able to run your command line (I just changed the docker image name, to point to public dockerhub), and it prints the help screen:

```auto
$ docker run --rm -it -e CASSANDRA_HOST=“xxxxxxx” -e CASSANDRA_PORT=9042 -e CASSANDRA_USER=user1 -e CASSANDRA_PASSWORD=‘xxxxxx#2020’ --entrypoint /bin/sh temporalio/admin-tools:0.26.0 -c temporal-cassandra-tool
NAME:
   temporal-cassandra-tool - Command line tool for temporal cassandra operations

USAGE:
   temporal-cassandra-tool [global options] command [command options] [arguments...]

```

This is what I would expect – running the tool without params should generate the help screen.

If I start passing parameters from the keyspace creation sequence ([Temporalio/admin-tools using docker to create cassandra schema](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/2)), the command attempts to do the thing, and fails:

```auto
$ docker run --rm -it -e CASSANDRA_HOST=“xxxxxxx” -e CASSANDRA_PORT=9042 -e CASSANDRA_USER=user1 -e CASSANDRA_PASSWORD=‘xxxxxx#2020’ --entrypoint /bin/sh temporalio/admin-tools:0.26.0 -c "temporal-cassandra-tool create-Keyspace -k temporal"
2020/08/05 15:52:13 gocql: dns error: lookup “xxxxxxx”: no such host
2020/08/05 15:52:13 error creating Keyspace:gocql: unable to create session: failed to resolve any of the provided hostnames

```

This is also what I expect, since I am providing made up values for `CASSANDRA_HOST`, and I don’t have a cassandra host running at `xxxxxxx`.

I am assuming that if I pass in real values for `CASSANDRA_*` env variables, the command would work as expected.

Is this not what you are seeing?

---

<div class="post-metadata">

**Author:** ![kasi](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kasi](https://community.temporal.io/u/kasi)\
**Post date:** [August 5, 2020, 6:44pm UTC](https://community.temporal.io/t/temporalio-admin-tools-using-docker-to-create-cassandra-schema/352/18 "2020-08-05T18:44:18Z")

</div>

Thanks a lot, Mark,I missed the quotes around the command
