Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
*.pyc

80 changes: 80 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
FROM cassandra:3.11.0

# trying to use cqlsh to interact with cassandra since installing cassandra-driver takes _forever_
# if the pip module is needed the package is:
# cassandra-driver==3.12.0

# install wget unzip and dig plus python modules
RUN set -ex \
&& apt-get update \
&& apt-get install --no-install-recommends -y wget unzip dnsutils python-dev gcc \
&& wget --quiet -O /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py \
&& python /tmp/get-pip.py \
&& pip install \
python-Consul==0.7.2 \
manta==2.6.0 \
pyyaml==3.12 \
&& apt-get purge -y python-dev gcc \
&& rm /tmp/get-pip.py \
&& rm -rf /var/lib/apt/lists/*

# Install Consul
# Releases at https://releases.hashicorp.com/consul
RUN set -ex \
&& export CONSUL_VERSION=1.0.1 \
&& export CONSUL_CHECKSUM=eac5755a1d19e4b93f6ce30caaf7b3bd8add4557b143890b1c07f5614a667a68 \
&& wget --quiet -O /tmp/consul.zip "https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip" \
&& echo "${CONSUL_CHECKSUM} /tmp/consul.zip" | sha256sum -c \
&& unzip /tmp/consul -d /usr/local/bin \
&& rm /tmp/consul.zip \
&& mkdir -p /etc/consul \
&& mkdir -p /var/lib/consul \
&& mkdir /config

# Install Consul template
# Releases at https://releases.hashicorp.com/consul-template/
RUN set -ex \
&& export CONSUL_TEMPLATE_VERSION=0.19.0 \
&& export CONSUL_TEMPLATE_CHECKSUM=31dda6ebc7bd7712598c6ac0337ce8fd8c533229887bd58e825757af879c5f9f \
&& wget --quiet -O /tmp/consul-template.zip "https://releases.hashicorp.com/consul-template/${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip" \
&& echo "${CONSUL_TEMPLATE_CHECKSUM} /tmp/consul-template.zip" | sha256sum -c \
&& unzip /tmp/consul-template.zip -d /usr/local/bin \
&& rm /tmp/consul-template.zip

# Add Containerpilot and set its configuration
ENV CONTAINERPILOT /etc/containerpilot.json5
ENV CONTAINERPILOT_VERSION 3.6.1

RUN export CONTAINERPILOT_CHECKSUM=57857530356708e9e8672d133b3126511fb785ab \
&& export archive=containerpilot-${CONTAINERPILOT_VERSION}.tar.gz \
&& wget --quiet -O /tmp/${archive} \
"https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VERSION}/${archive}" \
&& echo "${CONTAINERPILOT_CHECKSUM} /tmp/${archive}" | sha1sum -c \
&& tar zxf /tmp/${archive} -C /usr/local/bin \
&& rm /tmp/${archive}

COPY etc/containerpilot.json5 /etc/containerpilot.json5

### Cassandra-specific setup follows

COPY etc/containerpilot_handler /usr/local/bin/containerpilot_handler
COPY etc/containerpilot_handler.py /usr/local/bin/containerpilot_handler.py
# COPY etc/cassandra.yaml.ctmpl /etc/cassandra/cassandra.yaml.ctmpl

# the following COPY should be used for minimal-memory installations, potentially as low as 256m
COPY etc/cassandra.tiny.yaml.ctmpl /etc/cassandra/cassandra.yaml.ctmpl

# disable the automatic seed configuration that enables single-node bootstrapping
# the first line corresponds to "always set self as seed"
# the second line actually inserts CASSANDRA_SEEDS into the cassandra.yaml
RUN sed -ri '/CASSANDRA_SEEDS.*CASSANDRA_BROADCAST_ADDRESS/d' /docker-entrypoint.sh && \
sed -ri '/sed -ri.*CASSANDRA_SEEDS.*\/cassandra.yaml/d' /docker-entrypoint.sh

# TODO: uncomment for tiny cassandra nodes, don't forget to change the COPY above to cassandra.tiny.yaml.ctmpl
RUN sed -ri 's/^#MAX_HEAP_SIZE.*/MAX_HEAP_SIZE="64M"/' /etc/cassandra/cassandra-env.sh && \
sed -ri 's/^#HEAP_NEWSIZE.*/HEAP_NEWSIZE="12M"/' /etc/cassandra/cassandra-env.sh


EXPOSE 7000 7001 7199 9042 9160

ENTRYPOINT ["/usr/local/bin/containerpilot"]
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Autopilot Pattern Cassandra

A blueprint for running Apache Cassandra using the [Autopilot Pattern](http://autopilotpattern.io/).

Environment variables:

- `CASSANDRA_CLUSTER_NAME`: Name of cluster. Cassandra instances can only join a cluster with the
same `CASSANDRA_CLUSTER_NAME`. Changing this to something other than "Test Cluster"
is **strongly recommended**.
- `CASSANDRA_USER`: New user account to create upon cluster initialization. Setting this parameter
to something other than "cassandra" is **strongly recommended**.
- `CASSANDRA_PASSWORD`: password for `CASSANDRA_USER`.
- `CASSANDRA_KEYSPACES`: Comma-seperated list of keyspaces.
- `CASSANDRA_TOPOLOGY`: JSON map describing keyspaces and their respective datacenters and
replication factors, e.g. for a cluster deployed with at least 2 nodes in `us-east-1` and
`us-sw-1` Triton datacenters having a single keyspace named `demo`:
```
{ "demo": { "us-sw-1": 2 }, { "us-east-1": 2 } }
```

Notes:

```
cd examples/compose
docker-compose up -d --scale cassandra=3
# for a cqlsh shell:
docker-compose exec cassandra cqlsh cassandra

cqlsh> CREATE KEYSPACE demo WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': 2 };
USE demo;

```


# Credits

- Minimal Cassandra configuration based on John Berryman's [Building the Perfect Cassandra Test Environment](http://opensourceconnections.com/blog/2013/08/31/building-the-perfect-cassandra-test-environment/)
Loading