Exploring the run.sh script

The run.sh script requires some shell skills, but it's worth the effort. Since Docker allows running only one command, it is very common with non-trivial applications to have a launcher script that sets up the environment and prepares for the actual application. In this case, the image supports several deployment options (stateful set, replication controller, DaemonSet) that we'll cover later, and the run script accommodates it all by being very configurable via environment variables.

First, some local variables are set for the Cassandra configuration file at /etc/cassandra/cassandra.yaml. The CASSANDRA_CFG variable will be used in the rest of the script:

set -e CASSANDRA_CONF_DIR=/etc/cassandra CASSANDRA_CFG=$CASSANDRA_CONF_DIR/cassandra.yaml ...

Get Mastering Kubernetes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.