Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from mwringe/containers
Add docker images and kubernetes application definition
- Loading branch information
Showing
22 changed files
with
1,666 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<!-- | ||
Copyright 2014-2015 Red Hat, Inc. and/or its affiliates | ||
and other contributors as indicated by the @author tags. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.hawkular.metrics</groupId> | ||
<artifactId>hawkular-metrics-containers</artifactId> | ||
<version>0.3.2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>cassandra-docker</artifactId> | ||
<name>Cassandra Docker Image</name> | ||
<version>0.3.2-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.hawkular.metrics</groupId> | ||
<artifactId>cassandra-seed-provider</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<properties> | ||
<docker.baseimage>jboss/base-jdk:8</docker.baseimage> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jolokia</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<version>0.11.2</version> | ||
<configuration> | ||
<images> | ||
<image> | ||
<name>${cassandra.image}</name> | ||
<build> | ||
<assembly> | ||
<descriptor>../resources/assemblies/assemble-docker.xml</descriptor> | ||
</assembly> | ||
</build> | ||
</image> | ||
</images> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>docker-build</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jolokia</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<version>0.11.2</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# | ||
# Copyright 2014-2015 Red Hat, Inc. and/or its affiliates | ||
# and other contributors as indicated by the @author tags. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Hawkular-Metrics Cassandra Docker Image | ||
|
||
# Image based off of the jboss base image with JDK8 | ||
FROM ${docker.baseimage} | ||
|
||
# The image is maintained by the Hawkular Metrics team | ||
MAINTAINER Hawkular Metrics <hawkular-dev@lists.jboss.org> | ||
|
||
# Cassandra CQL transport port | ||
EXPOSE 9042 | ||
# Cassandra Thirft transport port | ||
EXPOSE 9160 | ||
# Cassandra TCP port | ||
EXPOSE 7000 | ||
# Cassandra SSL port | ||
EXPOSE 7001 | ||
|
||
# The Cassandra version | ||
ENV CASSANDRA_VERSION ${cassandra.version} | ||
|
||
# The Cassandra home location | ||
ENV CASSANDRA_HOME /opt/apache-cassandra | ||
|
||
# TODO: figure out if there is a better way to handle this | ||
# If we don't specify values here then the cassandra bin tries to automatically determine | ||
# the size which relies on other binaries not installed in the RHEL image. | ||
ENV MAX_HEAP_SIZE=512M | ||
ENV HEAP_NEWSIZE=100M | ||
|
||
# Become the root user to be able to install and setup Cassandra under /opt | ||
USER root | ||
|
||
# Copy the Cassandra binary to the /opt directory | ||
RUN cd /opt; \ | ||
curl -LO http://apache.mirrors.ionfish.org/cassandra/$CASSANDRA_VERSION/apache-cassandra-$CASSANDRA_VERSION-bin.tar.gz; \ | ||
tar xzf apache-cassandra-$CASSANDRA_VERSION-bin.tar.gz; \ | ||
rm apache-cassandra-$CASSANDRA_VERSION-bin.tar.gz; \ | ||
ln -s apache-cassandra-$CASSANDRA_VERSION apache-cassandra | ||
|
||
# Copy our version of the cassandra configuration file over to the filesystem | ||
COPY cassandra.yaml /opt/apache-cassandra/conf/cassandra.yaml | ||
|
||
# Copy the jar containing the kubernetes away jar | ||
COPY cassandra-seed-provider.jar /opt/apache-cassandra/lib/ | ||
|
||
# Copy our customized run script over to the cassandra bin directory | ||
COPY cassandra-docker.sh /opt/apache-cassandra/bin/ | ||
|
||
# TODO: remove this line once https://bugzilla.redhat.com/show_bug.cgi?id=1201848 has been fixed | ||
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
|
||
# Add the Cassandra bin directory to $PATH | ||
ENV PATH /opt/apache-cassandra/bin:$PATH | ||
|
||
# The name of the service exposing the Cassandra nodes | ||
ENV CASSANDRA_NODES_SERVICE_NAME hawkular-cassandra-nodes | ||
|
||
CMD ["/opt/apache-cassandra/bin/cassandra-docker.sh", "--seed_provider_classname=org.hawkular.openshift.cassandra.OpenshiftSeedProvider" ,"--cluster_name=hawkular-metrics"] |
104 changes: 104 additions & 0 deletions
104
containers/cassandra-docker/src/main/docker/cassandra-docker.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2014-2015 Red Hat, Inc. and/or its affiliates | ||
# and other contributors as indicated by the @author tags. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
for args in "$@" | ||
do | ||
case $args in | ||
--seeds=*) | ||
SEEDS="${args#*=}" | ||
;; | ||
--cluster_name=*) | ||
CLUSTER_NAME="${args#*=}" | ||
;; | ||
--data_volume=*) | ||
DATA_VOLUME="${args#*=}" | ||
;; | ||
--seed_provider_classname=*) | ||
SEED_PROVIDER_CLASSNAME="${args#*=}" | ||
;; | ||
--help) | ||
HELP=true | ||
;; | ||
esac | ||
done | ||
|
||
if [ -n "$HELP" ]; then | ||
echo | ||
echo Starts up a Cassandra Docker image | ||
echo | ||
echo Usage: [OPTIONS]... | ||
echo | ||
echo Options: | ||
echo " --seeds=SEEDS" | ||
echo " comma separated list of hosts to use as a seed list" | ||
echo " default: \$HOSTNAME" | ||
echo | ||
echo " --cluster_name=NAME" | ||
echo " the name to use for the cluster" | ||
echo " default: test_cluster" | ||
echo | ||
echo " --data_volume=VOLUME_PATH" | ||
echo " the path to where the data volume should be located" | ||
echo " default: \$CASSANDRA_HOME/data" | ||
echo | ||
echo " --seed_provider_classname" | ||
echo " the classname to use as the seed provider" | ||
echo " default: org.apache.cassandra.locator.SimpleSeedProdiver" | ||
echo | ||
exit 0 | ||
fi | ||
|
||
|
||
# set the hostname in the cassandra configuration file | ||
sed -i 's/${HOSTNAME}/'$HOSTNAME'/g' /opt/apache-cassandra/conf/cassandra.yaml | ||
|
||
# if the seed list is not set, set it to the hostname | ||
if [ -n "$SEEDS" ]; then | ||
sed -i 's/${SEEDS}/'$SEEDS'/g' /opt/apache-cassandra/conf/cassandra.yaml | ||
else | ||
sed -i 's/${SEEDS}/'$HOSTNAME'/g' /opt/apache-cassandra/conf/cassandra.yaml | ||
fi | ||
|
||
# set the cluster name if set, default to "test_cluster" if not set | ||
if [ -n "$CLUSTER_NAME" ]; then | ||
sed -i 's/${CLUSTER_NAME}/'$CLUSTER_NAME'/g' /opt/apache-cassandra/conf/cassandra.yaml | ||
else | ||
sed -i 's/${CLUSTER_NAME}/test_cluster/g' /opt/apache-cassandra/conf/cassandra.yaml | ||
fi | ||
|
||
# set the data volume if set, otherwise use the CASSANDRA_HOME location, otherwise default to '/cassandra_data' | ||
if [ -n "$DATA_VOLUME" ]; then | ||
sed -i 's#${DATA_VOLUME}#'$DATA_VOLUME'#g' /opt/apache-cassandra/conf/cassandra.yaml | ||
elif [ -n "$CASSANDRA_HOME" ]; then | ||
sed -i 's#${DATA_VOLUME}#'$CASSANDRA_HOME'/data#g' /opt/apache-cassandra/conf/cassandra.yaml | ||
else | ||
sed -i 's#${DATA_VOLUME}#/cassandra_data#g' /opt/apache-cassandra/conf/cassandra.yaml | ||
fi | ||
|
||
# set the seed provider class name, otherwise default to the SimpleSeedProvider | ||
if [ -n "$SEED_PROVIDER_CLASSNAME" ]; then | ||
sed -i 's#${SEED_PROVIDER_CLASSNAME}#'$SEED_PROVIDER_CLASSNAME'#g' /opt/apache-cassandra/conf/cassandra.yaml | ||
else | ||
sed -i 's#${SEED_PROVIDER_CLASSNAME}#org.apache.cassandra.locator.SimpleSeedProvider#g' /opt/apache-cassandra/conf/cassandra.yaml | ||
fi | ||
|
||
if [ -n "$CASSANDRA_HOME" ]; then | ||
exec ${CASSANDRA_HOME}/bin/cassandra -f | ||
else | ||
exec /opt/apache-cassandra/bin/cassandra -f | ||
fi |
Oops, something went wrong.